【问题标题】:ProgressbarStyle issues进度条样式问题
【发布时间】:2011-07-10 23:03:24
【问题描述】:

我有一个 ProgressbarStyle,我在其中将 TextBlock-Control 添加到网格“DeterminateRoot”。这个 TextBlock 应该显示一个状态文本,我在 CodeBehind 中手动更改它,这已经可以了。

这是我风格的一部分,我在标准 ProgressbarStyle 中进行了更改:

   <Grid x:Name="DeterminateRoot" Margin="1">
        <Rectangle x:Name="ProgressBarIndicator" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Left" Margin="{TemplateBinding BorderThickness}" RadiusY="1.5" RadiusX="1.5" StrokeThickness="0.5"/>
        <TextBlock x:Name="txtbStatusText" Text="5 of 20" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" FontWeight="Bold" FontFamily="Arial" FontSize="11"></TextBlock>
   </Grid>

我的问题是:如何在不更改进度条的标准颜色的情况下将 TextBlock-Text 的 Foregroundcolor 更改为黑色?因为,当我删除 Rectangle 的 Fill-Property (ProgressBarIndicator) 时,我可以更改 TextBlock 的 ForegroundColor,但我想保持 Progressbar 的标准外观!

提前感谢您的回答!

最好的问候 道吉

【问题讨论】:

    标签: xaml silverlight-4.0 styles


    【解决方案1】:

    正如您所说,如果您将展位属性设置为相同的 TemplateBinding,您的文本将不可见。您必须创建另一个属性,以便您可以独立管理它们。

    在您的代码中创建一个 Brush 类型的依赖属性,然后将您的 TextBlock 模板绑定到该属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-10
      • 2016-07-24
      • 1970-01-01
      • 2015-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多