This is a migrated thread and some comments may be shown as answers.

Dynamic ListBoxes

3 Answers 56 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Tomas
Top achievements
Rank 1
Tomas asked on 12 Nov 2013, 08:15 AM
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:
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.

3 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 14 Nov 2013, 11:07 AM
Hi Tomas,

Try replacing the ListBox with RadListBox and everything should start working as expected:

...
// var lb = new Telerik.Windows.Controls.ListBox();
var lb = new Telerik.Windows.Controls.RadListBox();
...

The first ListBox is obsolete and shouldn't be used any more, the correct one is RadListBox.

Hope this helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Tomas
Top achievements
Rank 1
answered on 15 Nov 2013, 11:13 AM
Hi Kalin,
thanks for the tip, but there is no RadListBox in the Telerik Controls library I have. Any ideas?
0
Kalin
Telerik team
answered on 15 Nov 2013, 04:02 PM
Hi Tomas,

The RadListBox should be present in the Telerik.Windows.Controls assembly as you can see in the Controls Dependencies article from our online help documentation. If you don't have it you are probably using old version and we recommend that you upgrade to the newest Q3 2013 version of the controls.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ListBox
Asked by
Tomas
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Tomas
Top achievements
Rank 1
Share this question
or