SelectionBoxTemplate not working of Combobox

2 posts, 1 answers
  1. Md.Hasanuzzaman
    Md.Hasanuzzaman avatar
    31 posts
    Member since:
    Apr 2011

    Posted 16 Jun 2012 Link to this post

    I am writing this lines of code 

      <telerik:RadComboBox Height="28" Margin="0,112.051,12,0" Grid.Row="1" VerticalAlignment="Top">
          <telerik:RadComboBox.SelectionBoxTemplate>
           <DataTemplate>
            <TextBlock Text="{Binding}" Foreground="Red"/>   
        </DataTemplate>   
       </telerik:RadComboBox.SelectionBoxTemplate>
          <telerik:RadComboBoxItem Content="Item 1"/>
          <telerik:RadComboBoxItem Content="Item 2"/>
          <telerik:RadComboBoxItem Content="Item 3"/>
         </telerik:RadComboBox>
    But this is not working. Please tell me what i am doing worng ?
    Thank you.
  2. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 18 Jun 2012 Link to this post

    Hi Hasanuzzaman,

    The RadComboBox control ignores the SelctionBoxTemplate property when there are statically declared RadComboBoxItem's and uses the ContentTemplate of the selected RadComboBoxItem. There are two solutions to this issue:

    1. To dynamically declare ComboBox items via bindings.
    2. Use <system:String> to statically declare content items. Here is a simple code representing that:
    <telerik:RadComboBox
                SelectionBoxTemplate="{StaticResource SelectionBoxTemplate}"
               
                >
                <system:String>Item 1</system:String>
                <system:String>Item 2</system:String>
                <system:String>Item 3</system:String>
    </telerik:RadComboBox>

    Hope this helps.

    All the best,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top