How to see the correct value when ItemTemplate specified?

3 posts, 0 answers
  1. Paolo
    Paolo avatar
    423 posts
    Member since:
    Jun 2009

    Posted 27 Jan 2012 Link to this post

    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. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 30 Jan 2012 Link to this post

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

  3. UI for WPF is Visual Studio 2017 Ready
  4. Paolo
    Paolo avatar
    423 posts
    Member since:
    Jun 2009

    Posted 30 Jan 2012 Link to this post

    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
Back to Top