问题
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
回答1:
simply use the ItemStringFormat property (works only if IsEditable="False")
<ComboBox ItemsSource="{Binding YourItems}"
DisplayMemberPath="MyDateField"
ItemStringFormat="{}{0:dd/MM/yyyy}" />
hope this helps
来源:https://stackoverflow.com/questions/9533986/stringformat-on-combobox-displaymemberpath