Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StringFormat on Combobox Displaymemberpath

I am trying to use StringFormat on DisplayMemberPath property of a ComboBox (WPF). But i don't know even if this is possible. can someone help me with some ideas.

I am trying to do something like this:

  <ComboBox DisplayMemberPath="{Binding Path=MyDateField, StringFormat={}{0:dd/MM/yyyy}}" Name="CmbName" Width="120" />

But it isn't working...

Thx All

like image 803
Diego Vieira Avatar asked Mar 02 '12 13:03

Diego Vieira


1 Answers

You can simply use the ItemStringFormat property.

Note: This works only if IsEditable is set to False

<ComboBox ItemsSource="{Binding YourItems}"
          DisplayMemberPath="MyDateField"
          ItemStringFormat="{}{0:dd/MM/yyyy}"
          IsEditable="False" />
like image 133
punker76 Avatar answered Oct 21 '22 05:10

punker76