开发者

ProgressbarStyle issues

开发者 https://www.devze.com 2023-03-19 10:37 出处:网络
I have a ProgressbarStyle in which I add a TextBlock-Control to the Grid \"DeterminateRoot\". This TextBlock should display a Status-Text, which I change manually in CodeBehind and this works already.

I have a ProgressbarStyle in which I add a TextBlock-Control to the Grid "DeterminateRoot". This TextBlock should display a Status-Text, which I change manually in CodeBehind and this works already.

Here is the part of my style, which I change in the standard 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>

My question is: How can I change the For开发者_Python百科egroundcolor of the TextBlock-Text to black, without changing the standardcolor of the progressbar? Because, when I delete the Fill-Property of the Rectangle (ProgressBarIndicator), then I can change the ForegroundColor of my TextBlock, but I want to keep the standardlook of the Progressbar!

Thank you in advance for your answers!

Best Regards Dougy


As you are stating, if you set booth properties to the same TemplateBinding your text will be invisible. You have to create another property so you can manage them independently.

Create in your code a dependency property of type Brush and then template binding your TextBlock to that property.

0

精彩评论

暂无评论...
验证码 换一张
取 消