主窗口用户界面
<Window x:Class="PrismSanity.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBlock Text="{Binding MyName}"></TextBlock>
</Grid>
</Window>
主窗口视图模型
public class MainWindowViewModel : BindableBase
{
private string _MyName = "John";
public string MyName
{
get { return _MyName = "John"; }
set { SetProperty(ref _MyName, value); }
}
}
我安装了 SNOOP 以查看发生了什么,但 VM 没有链接到视图。如果我用第二个视图做同样的事情,并使用
<ContectContainer>
<views:ViewA/>
</ContentContainer>
在主窗口中然后我让 ViewA 和 ViewAViewModel 链接正常。感谢您的关注。