The xaml:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox VerticalAlignment="Center" FocusManager.IsFocusScope="True" Grid.ColumnSpan="2" Name="SearchTextBox" Text="{Binding Path=SearchTerm.Value, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource FontStyle}" KeyUp="SearchTextBoxKeyUp" />
<DataGrid Grid.Row="1" ItemsSource="{Binding Path=EpisodesView, Mode=TwoWay}" MouseDoubleClick="ListViewDoubleClick" Style="{StaticResource FontStyle}" KeyUp="ListViewKeyup" Name="EpisodeList" AutoGenerateColumns="False" IsReadOnly="True"
d:DataContext="{d:DesignInstance vm:Episode}">
<DataGrid.Columns>
<DataGridTextColumn Header="File" Binding="{Binding File.Name}" />
<DataGridTextColumn Header="Age" Binding="{Binding PrettyAge}" SortMemberPath="Age" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
In the DataGrid at the bottom of the xaml above I am unable to BOTH get the design time d:DataContext DesignInstance references to be correct for both the binding of the DataGrid itself and the bindings of the specific columns.
If I include the the following snippet in DataGrid (as the xaml above) the DataGridTextColumns works, and I get intellisense for the column bindings:
d:DataContext="{d:DesignInstance vm:Episode}
But now the DataGrid binding intellisense no longer work. If I remove the snippet above the reverse happens: Intellisense for DataGrid binding works, but the column bindings don't.
To make it clear, this is only a design time problem. Everything works fine runtime.
Setting the d:DataContext
property changes the design time to use a new Episode
object created using the default constructor. You may need to set IsDesignTimeCreatable
to true
d:DataContext="{d:DesignInstance vm:Episode, d:IsDesignTimeCreatable=True}"
However I expect your issue is that Episode
is the item type and does not have a property EpisodesView
. You will need to set the data grid design time data context to a collection of Episodes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With