Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > ComboBox > How to see the correct value when ItemTemplate specified?

Not answered How to see the correct value when ItemTemplate specified?

Feed from this thread
  • Paolo Master avatar

    Posted on Jan 27, 2012 (permalink)

    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

    Reply

  • Boyan Boyan admin's avatar

    Posted on Jan 30, 2012 (permalink)

    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 >>

    Reply

  • Paolo Master avatar

    Posted on Jan 30, 2012 (permalink)

    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > ComboBox > How to see the correct value when ItemTemplate specified?
Related resources for "How to see the correct value when ItemTemplate specified?"

WPF ComboBox Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]