Combobox上的StringFormat Displaymemberpath [英] StringFormat on Combobox Displaymemberpath
本文介绍了Combobox上的StringFormat Displaymemberpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在ComboBox(WPF)的DisplayMemberPath属性上使用StringFormat。但我不知道即使这是可能的。
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.
我试图做这样的事情:
<ComboBox DisplayMemberPath="{Binding Path=MyDateField, StringFormat={}{0:dd/MM/yyyy}}" Name="CmbName" Width="120" />
但它不工作...
全部
推荐答案
只需使用ItemStringFormat属性(仅当IsEditable =False时才有效)
simply use the ItemStringFormat property (works only if IsEditable="False")
<ComboBox ItemsSource="{Binding YourItems}"
DisplayMemberPath="MyDateField"
ItemStringFormat="{}{0:dd/MM/yyyy}" />
希望这有助于
这篇关于Combobox上的StringFormat Displaymemberpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文