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

Custom ItemTemplate problem

0 Answers 72 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Aeroth
Top achievements
Rank 1
Aeroth asked on 07 Nov 2011, 02:49 PM
Hi Telerik support,

My purpose is that I need my ComboBox that can display both value and description (highlight), so I created my custom item template.
But, when I set the ComboBox IsEnabled to false, the ComboBox just dispeared, Did I go anything wrong or miss anything?

code snippets:

public class MyRadComboBox : RadComboBox
        {
            public MyRadComboBox()
            {
                DataTemplate selData = (DataTemplate)XamlReader.Load(
              @"<DataTemplate
                        xmlns=""http://schemas.microsoft.com/client/2007"">                   
                        <TextBlock Text=""{Binding Value}""/>                                           
                </DataTemplate>"
              );
 
                DataTemplate itemTmp = (DataTemplate)XamlReader.Load(
                    @"<DataTemplate
                        xmlns=""http://schemas.microsoft.com/client/2007"">
                    <StackPanel Orientation=""Horizontal"">
                        <TextBlock Text=""{Binding Value}""/>
                        <TextBlock Text="" ""/>
                        <TextBlock Text=""{Binding Description}"" Foreground=""Blue"" />
                    </StackPanel>
                </DataTemplate>");
 
 
                ItemsPanelTemplate itemsPanelTmp = (ItemsPanelTemplate)XamlReader.Load(
                    @"<ItemsPanelTemplate
                        xmlns=""http://schemas.microsoft.com/client/2007"">
                    <VirtualizingStackPanel />
                </ItemsPanelTemplate>");
 
 
                base.SelectionBoxTemplate = selData;
                base.ItemTemplate = itemTmp;
 
                base.ItemsPanel = itemsPanelTmp;
 
                base.SelectedValuePath = "Value";
                Telerik.Windows.Controls.TextSearch.SetTextPath(this, "Value");
            }
        }
 
public class MyComboBoxItem
        {
            public string Value { get; set; }
            public string Description { get; set; }
 
            public object DataContext { get; set; }
 
        }
 
public class MyComboBoxItemCollection : ObservableCollection<MyComboBoxItem>
        {
            public MyComboBoxItemCollection()
                : base()
            {
            }
        }

Thanks!

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Aeroth
Top achievements
Rank 1
Share this question
or