Would anyone know why I get the following error for the Databinding I'm doing?
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=TerminalName; DataItem=null; target element is 'LayoutDocument' (HashCode=15290806); target property is 'Title' (type 'String')
The View:
<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>
The ViewModel:
public class MainViewModel : ViewModelBase
{
private string _terminalName = "Python";
public MainViewModel()
{
}
public string TerminalName
{
get { return _terminalName; }
set { _terminalName = value; OnPropertyChanged(nameof(TerminalName)); }
}
}