gpt4 book ai didi

wpf - 组合框显示成员路径上的 StringFormat

转载 作者:行者123 更新时间:2023-12-03 11:31:30 24 4
gpt4 key购买 nike

我正在尝试在 ComboBox (WPF) 的 DisplayMemberPath 属性上使用 StringFormat。但我不知道这是否可能。有人可以帮我一些想法。

我正在尝试做这样的事情:

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

但它不起作用...

谢谢所有

最佳答案

您可以简单地使用 ItemStringFormat属性(property)。
注:这仅适用于 IsEditable设置为 False

<ComboBox ItemsSource="{Binding YourItems}"
DisplayMemberPath="MyDateField"
ItemStringFormat="{}{0:dd/MM/yyyy}"
IsEditable="False" />

关于wpf - 组合框显示成员路径上的 StringFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9533986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com