I have a source which is:
private ObservableCollection<Tuple<string,WrapPanel>> _list = new ObservableCollection<Tuple<string, WrapPanel>>();
Also I have a Listbox :
<ListBox SelectionMode="Single" x:Name="Display" VerticalAlignment="Top" HorizontalAlignment="Stretch" MinHeight="100" MinWidth="700" MaxHeight="250"
I set the itemssource from this listboz to my collection source :
Display.ItemsSource = _List;
I would like to display the content of WrapPanels ( Item2) into my listbox. I can not find the way to correctly visualize those wrapPanels obsjects .
I have tried different things in order to visualize those WrapPanels correctly
<!--1-->
<ListBox SelectionMode="Single" x:Name="MFPanelsDisplay" VerticalAlignment="Top" HorizontalAlignment="Stretch" MinHeight="100" MinWidth="700" MaxHeight="250" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" DataContext="{Binding}" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</Listbox>
<!--2-->
<ListBox SelectionMode="Single" x:Name="MFPanelsDisplay" VerticalAlignment="Top" HorizontalAlignment="Stretch" MinHeight="100" MinWidth="700" MaxHeight="250" DisplayMemberPath="Item2"/>
</ListBox.ItemTemplate>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<WrapPanel Grid.Column="0" Binding="{Binding Item2}" />
<TextBlock Grid.Column="1" Text="{Binding Item1}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
The result is always :
System.Windows.Controls.WrapPanel
System.Windows.Controls.WrapPanel
System.Windows.Controls.WrapPanel
System.Windows.Controls.WrapPanel
Any help would be good.