Hi everybody,
I need to solve the following problem: I have a dynamic set of properties (ObservableCollections of strings or integers) and for each of them I need to create a listbox. I have succeeded creating listboxes, however I cannot select items, I cannot scroll the content etc.
The code generating the list box follows:
The returned element is added as a child to a StackPanel.
I would appreciate any help.
I need to solve the following problem: I have a dynamic set of properties (ObservableCollections of strings or integers) and for each of them I need to create a listbox. I have succeeded creating listboxes, however I cannot select items, I cannot scroll the content etc.
The code generating the list box follows:
private
UIElement GetRadListBox(
int
number,
string
block)
{
var lb =
new
Telerik.Windows.Controls.ListBox();
lb.Name =
string
.Format(DYNAMIC_SELECTOR_NAME_FORMAT, block, number.ToString(
"00"
));
lb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
lb.SelectionMode = Telerik.Windows.Controls.SelectionMode.Multiple;
lb.Width = 240;
lb.MaxHeight = 300;
// bind item source
var binder =
new
Binding(
string
.Format(DYNAMIC_LIST_PROPERTY_FORMAT, block, number.ToString(
"00"
)));
binder.Mode = BindingMode.TwoWay;
lb.SetBinding(Telerik.Windows.Controls.ListBox.ItemsSourceProperty, binder);
lb.ItemsPanel = (ItemsPanelTemplate)Resources[
"VirtualizingStackPanelTemplate"
];
return
lb;
}
The returned element is added as a child to a StackPanel.
I would appreciate any help.