Hi I am having issues with understanding WPF databinding with nested objects.
I have a workgroup class containing a List of User_activation objects called ListMembers and I would like to display its properties. How do I access its nested properties? This class contains another object called User that has its username and ultimately I would like to display the username in the combobox instead of WPF_test.User_activation.
Below is the XAML code and corresponding layout:
<ListView x:Name="ListViewWorkgroups" VerticalAlignment="Top" Height="Auto" Width="Auto" ItemsSource="{Binding listWorkgroups}">
<ListView.View>
<GridView>
<GridViewColumn Width="auto" Header="Workgroup" DisplayMemberBinding="{Binding Name}"></GridViewColumn>
<GridViewColumn Width="auto" Header="Skills">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding ListSkills}" ></ComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="auto" Header="Members">
<GridViewColumn.CellTemplate>
<DataTemplate >
<ComboBox IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding ListMembers}" ></ComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
Layout: http://i50.tinypic.com/ydy5h.png
Thank you!
You need to set the ItemTemplate for the ComboBox
As an alternative, if you don’t need anything complex you can bind the DisplayMemberPath
You use the “.” to access properties like you would in normal c# code