Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF:2 string.format在同一文本块中?_Wpf_Geometry_Shape_Textblock_String.format - Fatal编程技术网

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:#,#}}" />