Wil*_*lem 9 wpf formatting label mask
我有一个标签:
<Label Name="lblBilledDate"
Content="{Binding Path=BilledDate, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">
</Label>
Run Code Online (Sandbox Code Playgroud)
它必然会DateTime有价值.
如何更改标签以显示此值: DisplayFormatString="dd MMM yyyy"
目前标签只是显示:2010年1月1日
我需要它显示:2010年1月1日
use*_*116 19
使用该ContentStringFormat属性.
<Label x:Name="SomeLabel"
Content="{Binding BilledDate}"
ContentStringFormat="dd MMM yyyy" />
Run Code Online (Sandbox Code Playgroud)
这是因为Label继承自ContentControl.任何ContentControl包含ContentStringFormat属性.此外,ItemsControl拥有ItemStringFormat和BindingBase拥有StringFormat.