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

Can't change RadComboBox's ItemsPanel

2 Answers 149 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
khiem nv
Top achievements
Rank 1
khiem nv asked on 23 Jun 2010, 11:14 AM
In my project, I want to change RadComboBox's ItemsPanel : Combo show ToolTip for String value too long and dropdownlist's width isn't spanned when value is too long. With short combos, when opened,  dropdownlist's width is 300 pixel. With combos that longer than 300 pixel, I want dropdownlist's width = combo's width. To do that, I used ItemTemplate for ToolTip and ItemsPanel for dropdownlist's width.
This work when combo's width is small but when combo's width too long, only dropdownlist's width is spanned, Yellow area show which item is selected not spanned. I implemented SizeChanged event, clear old ItemsPanel, pass new ItemsPanel for combo

Dim s As String = "<ItemsPanelTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""><VirtualizingStackPanel HorizontalAlignment=""Left"" Width=""" + newWidth.ToString + """/></ItemsPanelTemplate>" 
        Dim oItemsPanelTemplate As ItemsPanelTemplate = XamlReader.Load(s) 
        If cbo.ItemsPanel IsNot Nothing Then 
            cbo.ItemsPanel = Nothing 
        End If 
        cbo.ItemsPanel = oItemsPanelTemplate 
         
        Me.ApplyTemplate() 
 

Any way to fix this error?

2 Answers, 1 is accepted

Sort by
0
hvduc
Top achievements
Rank 1
answered on 24 Jun 2010, 11:15 AM
I found out If I implement VirtualizingStackPanel's SizeChanged event, I can change width of selection area. But it only works when I add event handler on Xaml. when use XamlReader.Load , it raise error: "System.Windows.Markup.XamlParseException: XamlReader.Load() does not accept event handlers" . Any idea to add event handler when use XamlReader.Load?
0
Konstantina
Telerik team
answered on 25 Jun 2010, 01:08 PM
Hello,

Thank you for your interest in our controls.

The ItemsPanel of the ComboBox can be changed only before the ComboBox is loaded. As for the Width of the ComboBox and the DropDown: the ComboBox to expand according to the width of the items you will need to remove the fixed Width. The width of the DropDown is known after the DropDown is open. So to customize it and make it the same as the ComboBox's you will have to edit the Template of the ComboBox.
About the XamlReader.Load() method - it does not have an overload for event handlers. For more information you can refer to these help articles:

If you have any other questions please let us know.

Greetings,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
khiem nv
Top achievements
Rank 1
Answers by
hvduc
Top achievements
Rank 1
Konstantina
Telerik team
Share this question
or