SelectionBoxTemplate ignored on non editable ComboBox

5 posts, 0 answers
  1. Michel
    Michel avatar
    5 posts
    Member since:
    Jun 2013

    Posted 29 Jul 2014 Link to this post

    <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?
  2. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 29 Jul 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Michel
    Michel avatar
    5 posts
    Member since:
    Jun 2013

    Posted 29 Jul 2014 in reply to Kalin Link to this post

    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.



  5. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 29 Jul 2014 Link to this post

    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.
     
  6. Michel
    Michel avatar
    5 posts
    Member since:
    Jun 2013

    Posted 29 Jul 2014 in reply to Kalin Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready