StringFormat on Combobox Displaymemberpath

北城以北 提交于 2020-01-29 03:23:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!