我正在尝试在ComboBox (WPF)的DisplayMemberPath属性上使用StringFormat。但我不知道这是否可能。有没有人能帮我出个主意。
我正在尝试这样做:
<ComboBox DisplayMemberPath="{Binding Path=MyDateField, StringFormat={}{0:dd/MM/yyyy}}" Name="CmbName" Width="120" />
但它不起作用。
Thx全部
发布于 2012-03-02 22:03:48
您可以简单地使用ItemStringFormat
属性。
注意:仅当IsEditable
设置为False
时,此选项才有效
<ComboBox ItemsSource="{Binding YourItems}"
DisplayMemberPath="MyDateField"
ItemStringFormat="{}{0:dd/MM/yyyy}"
IsEditable="False" />
https://stackoverflow.com/questions/9533986
复制相似问题