AutoWireViewModel
과 MefBootstrapper
을 결합하여 다양한 모듈의보기 간을 이동하려고합니다. 그러나 나는이 예외가 얻을 : xmlns:prism="http://www.codeplex.com/prism"
프리즘 AutoWireViewModel은 MEF와 호환됩니까?
XAML :
설정 특성 'Prism.Mvvm.ViewModelLocator.AutoWireViewModel을'
예외 사항이 코드 줄에 예외를 던졌다 :
<UserControl x:Class="Login.Views.LoginForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://www.codeplex.com/prism"
prism:ViewModelLocator.AutoWireViewModel="True" Width="350">
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF7B97D4" />
<GradientStop Color="#FF244C8D" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Login" TextWrapping="Wrap" Grid.RowSpan="1" Grid.ColumnSpan="2" FontSize="18" Foreground="#FF2F3806" Margin="8,8,8,8" />
<Label Grid.Row="1" Margin="10,10,10,10">username:</Label>
<TextBox x:Name="txtUsername" Text="{Binding UserName}" Grid.Row="1" Grid.Column="1" Margin="10,10,10,10" VerticalContentAlignment="Center"></TextBox>
<Label Grid.Row="2" Margin="10">password:</Label>
<PasswordBox x:Name="txtPassword" Grid.Row="2" Grid.Column="1" Margin="10,10,10,10" VerticalContentAlignment="Center" />
<Button x:Name="btnLogin" Grid.Row="3" Grid.RowSpan="1" Grid.ColumnSpan="2" Margin="10,10,10,10" Content="Log In" FontWeight="Bold" />
<TextBlock x:Name="txtMsg" Grid.Row="4" Grid.RowSpan="1" Grid.ColumnSpan="2" Margin="10,10,10,10" />
</Grid>
</UserControl>
보기 :
using System.ComponentModel.Composition;
using System.Windows.Controls;
namespace Login.Views
{
[Export("LoginForm")]
public partial class LoginForm : UserControl
{
public LoginForm()
{
InitializeComponent();
}
}
}
뷰 모델 :
using Prism.Mvvm;
namespace Login.ViewModels
{
public class LoginFormViewModel : BindableBase
{
private string _username = "unamegoeshere";
public string UserName
{
get { return _username; }
set { SetProperty(ref _username, value); }
}
}
}
쉘 :
[Export]
public partial class Shell : Window, IPartImportsSatisfiedNotification
{
private const string InitialModuleName = "LoginModule";
private static Uri InitialViewUri = new Uri("/LoginForm", UriKind.Relative);
public Shell()
{
InitializeComponent();
}
[Import(AllowRecomposition = false)]
public IModuleManager ModuleManager;
[Import(AllowRecomposition = false)]
public IRegionManager RegionManager;
public void OnImportsSatisfied()
{
this.ModuleManager.LoadModuleCompleted +=
(s, e) =>
{
if (e.ModuleInfo.ModuleName == InitialModuleName)
{
this.RegionManager.RequestNavigate(
RegionNames.MainContentRegion,
InitialViewUri);
}
};
}
어떤 프리즘 버전을 사용하고 있습니까? 나는 6.1로 이것을 재현 할 수 없다. –
동일 ... 프리즘 6.1 – keeg
양식이 표시됩니까? LoginForm이 실제로 표시되지 않으면 오류가 발생하지 않습니다. – keeg