WPF:2 string.format在同一文本块中?
我有一个WPF:2 string.format在同一文本块中?,wpf,geometry,shape,textblock,string.format,Wpf,Geometry,Shape,Textblock,String.format,我有一个圆形滑块,在这个滑块内我放置了文本块,显示滑块值,我还使用字符串.Format以int格式显示值,而不是双精度: <TextBlock Text="{Binding Path=Value, ElementName=knobSlider, StringFormat={}{0:#,#}}" Foreground="White" FontFamily="Trebuchet MS" FontSize="25" HorizontalAlignment="Center"
圆形滑块
,在这个滑块
内我放置了文本块
,显示滑块
值,我还使用字符串.Format
以int
格式显示值,而不是双精度
:
<TextBlock Text="{Binding Path=Value, ElementName=knobSlider, StringFormat={}{0:#,#}}" Foreground="White"
FontFamily="Trebuchet MS" FontSize="25" HorizontalAlignment="Center"
VerticalAlignment="Center" />
现在,您想在
滑块
值之前添加一个特定字符,例如“*”
,那么是否可以使用另一个字符串。format
?无需另一个StringFormat-如果您试图在值之前添加字符,只需用文本替换双大括号即可。我认为这就是你想要实现的目标:
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Trebuchet MS"
FontSize="25"
Foreground="White"
Text="{Binding Path=Value,
ElementName=knobSlider,
StringFormat=\*{0:#,#}}" />