There are no anymore multicolumn property in WPF ListBox, like in WinForm.
There are couple of more flexible options. Following please find how to add custom layouts to ListBox:
You have couple of options:
1. DockPanel
2. StackPanle
3. WrapPanel
And supposed you have:
ListBox myListBox = new ListBox();
FrameworkElementFactory factory = new FrameworkElementFactory(typeof(WrapPanel));
factory.SetValue(WrapPanel.HorizontalAlignmentProperty, HorizontalAlignment.Left); //not necessary
myListBox.ItemsPanel = new ItemsPanelTemplate(factory);
myListBox.ItemsPanel = new ItemsPanelTemplate(factory);
and change it back to default ListBox layout that you see regulary:
FrameworkElementFactory factory = new FrameworkElementFactory(typeof(StackPanel));
factory.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
myListBox.ItemsPanel = new ItemsPanelTemplate(factory);
May be more difficult, but more flexible, isn't it? J
אין תגובות:
הוסף רשומת תגובה