Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.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 通过XAML连接字符串_Wpf_Xaml_Concatenation_String.format - Fatal编程技术网

Wpf 通过XAML连接字符串

Wpf 通过XAML连接字符串,wpf,xaml,concatenation,string.format,Wpf,Xaml,Concatenation,String.format,我在ProgressBar中有一个标签,它从ProgressBar值中获取它的值,我想在ProgressBar值之后添加char% 我尝试了两个不起作用的选项: <Label Content="{Binding Progress}" ContentStringFormat="{}{0} %" /> <Label Content="{Binding Progress, StringFormat={}{0}%}" /> 例如: 这一切都非常类似于字符串。格式使用文本块 &

我在
ProgressBar
中有一个标签,它从
ProgressBar
值中获取它的值,我想在
ProgressBar
值之后添加char
%

我尝试了两个不起作用的选项:

<Label Content="{Binding Progress}" ContentStringFormat="{}{0} %" />
<Label Content="{Binding Progress, StringFormat={}{0}%}" />

例如:


这一切都非常类似于
字符串。格式

使用
文本块

<ProgressBar Value="50" Name="prog" ... />

<TextBlock Text="{Binding Path=Value, ElementName=prog, StringFormat={}{0}%}"/>

在我的案例中,我需要将绑定变量与静态字符串连接起来。与此代码完美配合!
ContentStringFormat="{}{0:P}"
<ProgressBar Value="50" Name="prog" ... />

<TextBlock Text="{Binding Path=Value, ElementName=prog, StringFormat={}{0}%}"/>