wpf 使用 StringFormat

在xaml里使用StringFormat,将两个字符串拼起来,一个字符串时固定不变的,一个字符串是动态绑定,如:平均密度:绑定的值

代码如下:

XML 复制代码
    <TextBlock Margin="0,0,0,0" Text="{Binding CellAverageDensity, StringFormat='{}平均密度:{0}'}" Style="{StaticResource TextBlockMediumStyle}" HorizontalAlignment="Left"/>

在cs里,用的是 String.Format方法

cs 复制代码
     string msg = String.Format("{0}  {1}  {2:x2} {3:x2} {4:x2} {5:x2} {6:x2} {7:x2} {8:x2} {9:x2}   to handle {10}",
                                             id, dlc, data[0], data[1], data[2], data[3], data[4],
                                             data[5], data[6], data[7], _handle);
相关推荐
Magnum Lehar4 小时前
wpf游戏引擎content/Asset.cs
游戏引擎·wpf
Magnum Lehar5 小时前
wpf游戏引擎下的Geometry实现
java·游戏引擎·wpf
Java Fans5 小时前
WPF调用Python心率监测脚本解决方案
开发语言·python·wpf
Magnum Lehar21 小时前
wpf游戏引擎的script实现
游戏引擎·wpf
CPU不够了2 天前
window7 wpf程序打不开问题排查及处理
windows·.net·wpf
界面开发小八哥2 天前
界面组件DevExpress WPF中文教程:Grid - 如何获取行句柄?
wpf·界面控件·devexpress·ui开发·用户界面
YUNYINGXIA3 天前
Redis集群
redis·wpf
大霸王龙4 天前
系统模块与功能设计框架
人工智能·wpf
明耀5 天前
WPF DataGrid 默认显示行号
wpf
lph19725 天前
wpf的converter
wpf