有谁知道我为什么会在数据处理中遇到以下错误?
System.Windows.Data错误:2:找不到管理FrameworkElement 或目标元素的FrameworkContentElement。 BindingExpression:路径= TerminalName;的DataItem = NULL;目标元素是 ' LayoutDocument' (的HashCode = 15290806);目标财产是'标题' (类型 '字符串&#39)
观点:
<Window x:Class="Understanding.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:local="clr-namespace:Understanding"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MainViewModel x:Name="ViewModel"/>
</Window.DataContext>
<Grid>
<xcad:DockingManager AllowMixedOrientation="True">
<xcad:LayoutRoot x:Name="_layoutRoot">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutDocumentPane ShowHeader="True">
<xcad:LayoutDocument ContentId="Terminal" Title="{Binding Path=TerminalName}" CanClose="True">
<TextBlock Text="This is an example"/>
</xcad:LayoutDocument>
</xcad:LayoutDocumentPane>
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
</Grid>
</Window>
ViewModel:
public class MainViewModel : ViewModelBase
{
private string _terminalName = "Python";
public MainViewModel()
{
}
public string TerminalName
{
get { return _terminalName; }
set { _terminalName = value; OnPropertyChanged(nameof(TerminalName)); }
}
}