I have a list of employees entities, bound to a listbox that implements a DataTemplate.
DataTemplate:
<DataTemplate x:Key="EmployeeTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Vertical"
VerticalAlignment="Top" Margin="2">
<TextBlock Foreground="Black" FontSize="12"
VerticalAlignment="Bottom" Text="{Binding Path=Test}">
</TextBlock>
<TextBlock Foreground="Black" FontSize="12"
VerticalAlignment="Bottom" Text="{Binding Path=Language.ContactNumber}">
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Vertical"
VerticalAlignment="Top" Margin="2">
<TextBlock Foreground="Black" FontSize="12"
VerticalAlignment="Bottom" Text="{Binding Path=IdNumber}">
</TextBlock>
<TextBlock Foreground="Black" FontSize="12"
VerticalAlignment="Bottom" Text="{Binding Path=ContactNumber}">
</TextBlock>
</StackPanel>
</Grid>
</DataTemplate>
Listbox:
<ListBox ItemsSource="{Binding Path=Employees}"
x:Name="ListBoxEmployees"
ItemTemplate="{DynamicResource EmployeeTemplate}"
BorderBrush="DarkGray"
Margin="5"/>
My Datacontext is a viewModel called EmployeeViewModel, it contains the collection of employees. This binding works fine, the employees gets displayed and all is good. The Problem is that the EmployeeViewModel inherits from a base abstract ViewModel that contains a static property called Language. This model has various fields that I bind labels to all over the app. The values in the data template does not work. Why?
Additional info: This listbox is in a usercontrol on the mainwindow.xaml
Edit:
xmlns:viewModels="clr-namespace:POC.DesktopClient.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance viewModels:EmployeeViewModel}"
These XML namespaces at the top of my usercontrol allows xaml intelisense when binding. The intelisence does pick up the language object and its fields within.