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

ComboBox DisplaymemberPath Binding

1 Answer 433 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Manas
Top achievements
Rank 1
Manas asked on 01 Oct 2010, 08:31 PM
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

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 07 Oct 2010, 08:43 AM
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
Tags
ComboBox
Asked by
Manas
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or