ComboBox DisplaymemberPath Binding

2 posts, 0 answers
  1. Manas
    Manas avatar
    4 posts
    Member since:
    Apr 2010

    Posted 01 Oct 2010 Link to this post

    Hello there,
    I need to convert the Transactiondate (of type DateTime) to show in 24 hour format in a Combobox
    with IsEditable=True and upon selection of an item the ComboBox needs to show the selected date in 24hr format.

    This version converts the dates to 24hr format but up on Item selection it shows the class name
    instead of the selected date in 24 hr format): What am I doing wrong or missing?

    <telerikInput:RadComboBox x:Name="ccTransactionDate" IsEditable="True" Grid.Row="2" Grid.Column="1">
    <telerikInput:RadComboBox.ItemTemplate>
    <DataTemplate>
    <TextBlock Text="{Binding Path=TransactionDate, StringFormat='MM/dd/yyyy HH:mm:ss'}" />
    </DataTemplate>
    </telerikInput:RadComboBox.ItemTemplate>
    </telerikInput:RadComboBox>







    However when IsEditable is False it Works fine (but don't want to use this because want editable ComboBox):



    <telerikInput:RadComboBox x:Name="ccTransactionDate" IsEditable="False" Grid.Row="2" Grid.Column="1">
    <telerikInput:RadComboBox.ItemTemplate>
    <DataTemplate>
    <TextBlock Text="{Binding Path=TransactionDate, StringFormat='MM/dd/yyyy HH:mm:ss'}" />
    </DataTemplate>
    </telerikInput:RadComboBox.ItemTemplate>
    </telerikInput:RadComboBox>







    Thanks,
    Manas
  2. George
    Admin
    George avatar
    1332 posts

    Posted 07 Oct 2010 Link to this post

    Hi Manas,

    I would suggest you to use the attached property TextSearch.TextPath in Telerik.Windows.Controls.dll assembly:  

    <telerikInput:RadComboBox x:Name="ccTransactionDate" IsEditable="True" Grid.Row="2" Grid.Column="1" telerik:TextSearch.TextPath="TransactionDate">
    <telerikInput:RadComboBox.ItemTemplate>
    <DataTemplate>
    <TextBlock Text="{Binding Path=TransactionDate, StringFormat='MM/dd/yyyy HH:mm:ss'}" />
    </DataTemplate>
    </telerikInput:RadComboBox.ItemTemplate>
    </telerikInput:RadComboBox>

    Please, pay attention to that the selected item displayed in the TextBlock cannot be formatted. In this case you could use for the binding a property that returns already formatted DateTime string.

    I hope this helps.

    Sincerely yours,
    George
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top