相关疑难解决方法(0)

如何将多个值绑定到单个WPF TextBlock?

我目前正在使用TextBlock以下命令绑定名为的属性的值Name:

<TextBlock Text="{Binding Name}" />
Run Code Online (Sandbox Code Playgroud)

现在,我想绑定另一个名为ID相同的属性TextBlock.

是否可以将两个或多个值绑定到同一个值TextBlock?是否可以通过简单的连接来完成Name + ID,如果没有,可以如何处理它?

data-binding wpf binding textblock multibinding

191
推荐指数
4
解决办法
16万
查看次数

绑定上的StringFormat

视图:

<TextBlock Text="{Binding Date}"/>
Run Code Online (Sandbox Code Playgroud)

我希望将日期格式化为"dd/MM/yyyy",换句话说,没有时间.

我试过了:<TextBlock Text="{Binding Date, StringFormat={}{0:dd/MM/yyyy}}"/>但它不起作用.

给我一个错误:在'Binding'类型中找不到属性'StringFormat'.

c# xaml string-formatting date-formatting uwp

19
推荐指数
4
解决办法
2万
查看次数