Let's say I have a ListBox which binds to stuff in code-behind:
<ListBox x:Name="list"> <ListBox.ItemTemplate> <DataTemplate> <ListBoxItem Content="{Binding Name}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <TextBox x:Name="name" Text="{Binding ElementName=list, Path=SelectedItem.Name, Mode=TwoWay" /> <TextBox x:Name="contents" Text="{Binding ElementName=list, Path=SelectedItem.Contents, Mode=TwoWay" /> Code behind:
public class Dude { public String Name { get; set; } public String Contents { get; set; } } Now the above does just what I want it to. When an item in the listbox is selected, The textboxes update to show what was selected in the listbox.
But what I am now trying to do is expand on my Dude class by adding a Dictionary to it:
public class Dude { public string Name { get; set; } public string Contents { get; set; } public Dictionary<String, String> Tasks { get; set; } } In the hopes that I can:
Click an Item in the ListBox, have the corresponding item's Name and Contents properties display in their respective TextBoxes and then Append to the contents textbox the Key/Value of the Dictionary's contents.
But I don't know how I can go that deep. It kinda feels like I'm going multiple levels, would something like Multidimensional binding be what I need?
Are there any (simple) samples you have, or have seen? Docs, articles, tutorials?
Any help is much appreciated.
Thank you