1 引用Prism.DryIOC
2 xmlns:prism="http://prismlibrary.com/" Application 改成 prism:PrismApplication
3 Windows xmal中增加 prism:ViewModelLocator.AutoWireViewModel="True"
4 文件夹Views ViewModels
记录一次理解
Xmal
<Grid> <TextBlock x:Name="TT" Text="{Binding VName}" /> <Button x:Name="Btn" Margin="264,230,219,110" Command="{Binding BtnCommand}" /> </Grid>
ManiWindows.cs
public MainWindow() { InitializeComponent(); TT.Text = "MainWindow 初始化"; }
在ViewModel中
public MainWindowViewModel()
{
VName = "ViewMode Init";
BtnCommand = new DelegateCommand(() => { VName = "ViewMode Btn"; }) }
public DelegateCommand BtnCommand; private string _VName;
public string VName
{ get { return _VName; }
set {
_VName = value;
RaisePropertyChanged();
}
}