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

SelectionBoxTemplate ignored on non editable ComboBox

4 Answers 135 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michel
Top achievements
Rank 1
Michel asked on 29 Jul 2014, 08:18 AM
<DataTemplate x:Key="MultiComboBoxView">
   <telerik:RadComboBox ItemsSource="{Binding ValueEnum}"
                  Width="220" Height="30"
                  ItemTemplate="{StaticResource RadComboBoxItemTemplate}">
        <telerik:RadComboBox.SelectionBoxTemplate>
            <DataTemplate>
                 <TextBlock Text="{Binding SelectedItemsText}" />
            </DataTemplate>
        </telerik:RadComboBox.SelectionBoxTemplate>
    </telerik:RadComboBox>
</DataTemplate>

Hi,

My Combobox is not editable and does not have as source static items, but selectionBoxTemplate is ignored though.
I tried with hard coded string instead of a binding, but it's still been ignored.
What am I doing wrong?

4 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 29 Jul 2014, 11:18 AM
Hi Michel,

I tested the provided project and didn't face any issues with the SelectionBoxTemplate - I'm attaching my sample project here. Could you please check it and let me know if it helps.

Hope it will work for you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Michel
Top achievements
Rank 1
answered on 29 Jul 2014, 11:56 AM
No, the template is still ignored.
I don't know if it can help you, but the source I'm using (ValueEnum) is a List<object> and in this case a list of the fllowing class.

public class MultiComboItemData
   {
       private object _object;
       private bool _isSelected;
 
       public object Object
       {
           get
           {
               return _object;
           }
           set
           {
               if (_object != value)
               {
                   _object = value;
                   OnPropertyChanged("Object");
               }
           }
       }
 
       public bool IsSelected
       {
           get
           {
 
               return _isSelected;
           }
           set
           {
               if (_isSelected != value)
               {
                   _isSelected = value;
                   OnPropertyChanged("IsSelected");
               }
           }
       }
 
       public MultiComboItemData(object obj, bool selected)
       {
           _object = obj;
           _isSelected = selected;
 
       }
 
       protected virtual void OnPropertyChanged(String propertyName)
       {
           if (String.IsNullOrEmpty(propertyName))
           {
               return;
           }
           if (PropertyChanged != null)
           {
               PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
           }
       }
 
       public event PropertyChangedEventHandler PropertyChanged;
    
   }
 
This work fine, Template is applied with checkboxes

Again, even if I replace the binding with "Test" in the text property of the textblock inside my SelectionBoxTemplate, I still see nothing displayed.



0
Kalin
Telerik team
answered on 29 Jul 2014, 12:03 PM
Hi,

Where is the SelectedItemsText property used for the binding the SelectionBoxTemplate? However I noticed you have defined the ComboBox inside of the DataTemplate, where exactly you use that Template? Can you can provide some more sample code?

I'm looking forward to hearing from you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Michel
Top achievements
Rank 1
answered on 29 Jul 2014, 12:34 PM
My bad :)

I added SelectionIndex="0" and it works fine.
As I have checkboxes in my template, I didn't select any item but just checked a checkbox.
Hence SelectionBoxTemplate was never used.

Thank you for your time
Tags
ComboBox
Asked by
Michel
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Michel
Top achievements
Rank 1
Share this question
or