【发布时间】:2018-02-21 14:00:19
【问题描述】:
我有这个GridViewColumn.CellTemplate:
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Grid Margin="-6,0,0,0">
<ProgressBar Name="progressBarColumn"
Minimum="0"
Maximum="100"
Value="{Binding Progress, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource CustomProgressBar4}"
Width="350"
Margin="0,0,0,0"/>
<TextBlock x:Name="fileNameTextBlock"
Text="{Binding File}"
VerticalAlignment="Center"
Margin="10,0,0,0"/>
</Grid>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
在我的Progress-Bar 中而不是显示Percentage 我将其更改为显示我的绑定文件:
Text="{Binding File}"
还有我的Style:
<Style x:Key="CustomProgressBar4" TargetType="ProgressBar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ProgressBar" >
<Grid x:Name="Root">
<Border Name="PART_Track"
CornerRadius="5"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding Background}"
BorderThickness="1"/>
<Border Name="PART_Indicator"
CornerRadius="5"
Background="{TemplateBinding Foreground}"
BorderBrush="{TemplateBinding Foreground}"
BorderThickness="1"
HorizontalAlignment="Left" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
所以我的进度条根据我的Progress 值(绑定)填充,我想添加简单的Label\TextBlock,它将位于我的Progress-Bar 的右侧,并将显示我的Progress 值。
有什么建议吗?
【问题讨论】:
-
在模板中的网格内添加
<TextBlock Text="{TemplateBinding Value}" HorizontalAlignment="Right"/>? -
这也应该按值移动
-
“将位于右侧的简单标签\文本块”与“应根据值移动”矛盾
-
好的,我在我的风格中添加了这个,但我看不到它
标签: wpf styles progress-bar