progressbar 进度变色

来源:互联网 发布:淘宝上zara是真的吗 编辑:程序博客网 时间:2024/04/26 00:08

<Border Margin="50" BorderBrush="Red" Height="20" BorderThickness="2" HorizontalAlignment="Left" CornerRadius="5" x:Name="brDemo">
<ProgressBar HorizontalAlignment="Center" Padding="2" x:Name="abc" Width="300"
Value="50">
<ProgressBar.Template>
<ControlTemplate>
<StackPanel>
<Rectangle Name="PART_Track" Height="0" Width="300" Fill="green" />
<Rectangle Name="PART_Indicator" Height="20" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Left"/>
</StackPanel>
</ControlTemplate>
</ProgressBar.Template>
</ProgressBar>
</Border>

 

后台

DependencyObject d1 = this.abc.Template.LoadContent();
Rectangle rectangle = LogicalTreeHelper.FindLogicalNode(d1, "PART_Indicator") as Rectangle;
brDemo.BorderBrush = Brushes.Blue;
abc.Foreground = Brushes.Red;

原创粉丝点击