I have two situations I believe are the same. One binds, the other doesn't. This is .net 4.6 with entity framework 6.
This one works, it binds ID_GDB successfully.
<ContentControl x:Name="CurrentItemPanel" Grid.Row="2" Content="{Binding SelectedItem, ElementName=MainList}" Visibility="{Binding SelectedItems.Count, ElementName=MainList,Converter={StaticResource intToVisibilityConverter}}"><ContentControl.Resources><DataTemplate DataType="{x:Type local:Game}"><DockPanel><StackPanel x:Name="GDBID_Stackpanel" Orientation="Horizontal" DockPanel.Dock="Top" Margin="10,0,0,0"><TextBlock Text="GDBID: " Style="{StaticResource Heading1}" DockPanel.Dock="Top"/><TextBlock Text="{Binding ID_GDB}" Style="{StaticResource Heading1}" DockPanel.Dock="Top"/></StackPanel></DockPanel></DataTemplate></ContentControl.Resources></ContentControl>
public partial class Game : INotifyPropertyChanged { public long? ID_GDB { get { return Releases[0].ID_GDB; } } }
This one does not work. It does not bind Matched.
<StackPanel x:Name="HeaderBar" Orientation="Horizontal" DataContext="{Binding SelectedItem, ElementName=PlatformList}"><TextBlock x:Name="Head2" Text="Matched: " Style="{StaticResource Heading1}" VerticalAlignment="Center" Margin="20,0,0,0"/><TextBlock x:Name="Head3" Text="{Binding Matched}" Style="{StaticResource Heading1}" VerticalAlignment="Center"/></StackPanel>
public partial class DMPlatform : INotifyPropertyChanged { int Matched { get { return DMReleases.Where(x => x.ID_GDB != null).Count(); } } }
- Much code that I believe to be irrelevant is omitted.
- These are in different windows.
- PlatformsList is a ListBox bound to a List<DMPlatforms>.
- The DataContext of the HeaderBar Stackpanel is binding correctly to the SelectedItem in PlatformsList
- The Matched property returns the correct number
- I have tried many things, including rewriting the second control to be essentially word-for-word identical to the first.