I have a listbox and I want to show two properties from my object.
For one property it is pretty easy:
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name} "></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
However I would like something like
Name - GroupName not just Name…
I know that it is easy, but I am confused. I don’t know how to add two textblocks into the same level of the XAML hierarchy.
You can do this a couple of ways. One is with a
MultiBindingand aStringFormatThe second is option is to set the root element of your
DataTemplateto something that can have more than one child, like aStackPaneland have toTextBlockcontrols each bound to the appropriate value.I prefer the first option.