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

SelectionBoxItemTemplate issue

2 Answers 182 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 12 May 2009, 09:46 PM
Hello,

Based on one of your examples I created a RadComboBox in which I want to display certain information when the comboBox (Name, Site, Department) is open and when one item is selected the comboBox displays only the Name.

I created the corresponding templates, and it displays the list correctly, but when one item is selected the ComboBox shows the class name that I'm binding to the control.

Please, let me know what I'm missing.   I'm using IE7, and the version of my controls is 2009.1.508.1020  (I had to use this internal release since I needed to solve an issue with rearranging grid columns contained in RadWindows)

<UserControl x:Class="Intel.Cqn.FamisLight.Silverlight.UserControls.EmployeeSearch" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"      
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
    >     
    <Grid x:Name="LayoutRoot" Background="White">     
        <Grid.Resources>             
            <DataTemplate x:Key="ComboBoxCustomTemplate"
                <StackPanel Orientation="Vertical"
                    <TextBlock FontWeight="Bold" Grid.ColumnSpan="2" Text="{Binding Name}" /> 
                    <StackPanel Orientation="Horizontal"
                        <TextBlock Foreground="RoyalBlue" Text="Department: " /> 
                        <TextBlock Text="{Binding Department}" /> 
                        <TextBlock Foreground="RoyalBlue"  Text="  Site: " /> 
                        <TextBlock Text="{Binding Site}" /> 
                    </StackPanel>                         
                </StackPanel>                 
            </DataTemplate> 
            <DataTemplate x:Key="ComboBoxSimpleTemplate">                 
                <TextBlock Text="{Binding Name}" />                 
            </DataTemplate> 
        </Grid.Resources>         
        <telerik:RadComboBox Name="LookupComboBox" 
                             IsEditable="True" 
                             ItemTemplate="{StaticResource ComboBoxCustomTemplate}" 
                             SelectionBoxItemTemplate="{StaticResource ComboBoxSimpleTemplate}"                              
                             >              
        </telerik:RadComboBox> 
    </Grid> 
</UserControl> 

Thanks very much for your help,
Marco



2 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 13 May 2009, 08:20 AM
Hi Marco,

When the IsEditable property is set to True RadComboBox uses different control template, which puts a TextBox in the selection box area, hence the SelectionBoxItemTemplate is not used anymore. To display the value of a property of your data object you need to use the TextSearch.TextPath attached property. Here is the updated RadComboBox declaration (note that I changed the xml namespaces):
<UserControl x:Class="SilverlightApplication1.SilverlightControl1"
  xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
  xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input">
 <Grid x:Name="LayoutRoot" Background="White">
  <Grid.Resources>
   <DataTemplate x:Key="ComboBoxCustomTemplate">
    <StackPanel Orientation="Vertical">
     <TextBlock FontWeight="Bold" Grid.ColumnSpan="2" Text="{Binding Name}" />
     <StackPanel Orientation="Horizontal">
      <TextBlock Foreground="RoyalBlue" Text="Department: " />
      <TextBlock Text="{Binding Department}" />
      <TextBlock Foreground="RoyalBlue" Text="  Site: " />
      <TextBlock Text="{Binding Site}" />
     </StackPanel>
    </StackPanel>
   </DataTemplate>
  </Grid.Resources>
  <telerikInput:RadComboBox Name="LookupComboBox" IsEditable="True"
    ItemTemplate="{StaticResource ComboBoxCustomTemplate}"
    telerik:TextSearch.TextPath="Name">
  </telerikInput:RadComboBox>
 </Grid>
</UserControl>


Sincerely yours,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Marco
Top achievements
Rank 1
answered on 13 May 2009, 03:16 PM
Cool, it works perfectly!
Thanks Valeri for your precise and timely response! :)
Tags
ComboBox
Asked by
Marco
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Marco
Top achievements
Rank 1
Share this question
or