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

How to see the correct value when ItemTemplate specified?

2 Answers 38 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 27 Jan 2012, 04:51 PM
Hello,
I've a combobox defined as

    <telerik:RadComboBox Grid.Row="0" IsEditable="true" SelectedItem="{Binding SelectedDateMode=TwoWay}"
                             x:Name="ComboBox" Height="30" Width="150" ItemsSource="{Binding Collection, Mode=OneWay}"
                             ItemTemplateSelector="{StaticResource itemTemplateSelector}" OpenDropDownOnFocus="True" />

and the template I'm going to use is

 <DataTemplate x:Key="datetimeDataTemplateSelector">
                <TextBlock Text="{Binding Data}"/>
            </DataTemplate>

it's bound to an object of type

   public class TestObject : INotifyPropertyChanged
    {
        public bool IsGeneric { get; set; }

        public DateTime? Data { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
and when the dropdown is open I got the data shown.. when I select an Item I got for the itemtemplate RadControlsWpfApp2.TestObject

Since I cannot specify a DisplayMember how can I tell to show the Data value?
Thanks

2 Answers, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 30 Jan 2012, 03:21 PM
Hi,

You should use the attached property telerik:TextSearch.TextPath in order to show the correct data in the textbox of the RadComboBox. For more info on how to properly bind RadComboBox you can take a look at this example.

Let us know if you have further questions.

Regards,
Boyan
the Telerik team

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

0
Michele
Top achievements
Rank 2
answered on 30 Jan 2012, 03:29 PM
Hello Boyan,
That's ok thanks... I've got problem formatting it a DateTime in the edittemplate of a combobox... it alsways show me the time...
I've opened a ticket for another question if you want to look at that code, I've also asked help on this

Thanks
Tags
ComboBox
Asked by
Michele
Top achievements
Rank 2
Answers by
Boyan
Telerik team
Michele
Top achievements
Rank 2
Share this question
or