【问题标题】:Changed ProgressBar color in XAML, now animation is gone更改 XAML 中的 ProgressBar 颜色,现在动画消失了
【发布时间】:2015-03-30 15:40:54
【问题描述】:

我成功地更改了 XAML 中确定进度条的颜色,如下所示:

<Style TargetType="{x:Type ProgressBar}">
        <Setter Property="Foreground">
            <Setter.Value>
                <LinearGradientBrush x:Name="Foreground" EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA5C5D1" Offset="1"/>
                    <GradientStop Color="#BFA5C5D1" Offset="0.052"/>
                    <GradientStop Color="#BFA5C5D1"/>
                    <GradientStop Color="#F2A5C5D1" Offset="0.937"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush  EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#66D8D8D8" Offset="0"/>
                    <GradientStop Color="#7FC1C1C1" Offset="1"/>
                    <GradientStop Color="#72CFCFCF" Offset="0.721"/>
                    <GradientStop Color="#66DCDCDC" Offset="0.499"/>
                    <GradientStop Color="#66EAEAEA" Offset="0.068"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid Margin="1">
                        <Rectangle x:Name="opacityMask" RadiusX="4" RadiusY="4" Fill="{TemplateBinding Background}" Margin="0"/>
                        <Grid Margin="-1">
                            <Grid.OpacityMask>
                                <VisualBrush Visual="{Binding ElementName=opacityMask}"/>
                            </Grid.OpacityMask>
                            <Rectangle x:Name="PART_Track" RadiusX="{Binding ElementName=opacityMask, Path=RadiusX}" RadiusY="{Binding ElementName=opacityMask, Path=RadiusY}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" Fill="{TemplateBinding Background}"/>
                            <Rectangle x:Name="PART_Indicator" RadiusX="{Binding ElementName=opacityMask, Path=RadiusX}" RadiusY="{Binding ElementName=opacityMask, Path=RadiusY}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" HorizontalAlignment="Left" Fill="{TemplateBinding Foreground}" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

但是,我希望栏保持我更改样式之前的发光动画。目前,当我设置 IsDeterminate="True"; 时根本没有动画发生。它只是静态填充了我在 XAML 中指定的前景色。

我怎样才能恢复动画?

【问题讨论】:

    标签: c# wpf xaml animation progress-bar


    【解决方案1】:

    您在控制模板中缺少故事野猪。这是来自 MSDN 的默认模板:

    https://msdn.microsoft.com/en-us/library/ms750638(v=vs.110).aspx

    【讨论】:

      【解决方案2】:

      如果你只想改变颜色,那么请覆盖它

      <SolidColorBrush x:Key="ProgressBarBackgroundThemeBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
      

      或者如果您也想更改其他内容

      <Style TargetType="ProgressBar">
          <Setter Property="Foreground" Value="{StaticResource ProgressBarForegroundThemeBrush}" />
          <Setter Property="Background" Value="{StaticResource ProgressBarBackgroundThemeBrush}" />
          <Setter Property="BorderBrush" Value="{StaticResource ProgressBarBorderThemeBrush}" />
          <Setter Property="BorderThickness" Value="{StaticResource ProgressBarBorderThemeThickness}" />
          <Setter Property="Maximum" Value="100" />
          <Setter Property="MinHeight" Value="{StaticResource ProgressBarThemeMinHeight}" />
          <Setter Property="IsTabStop" Value="False" />
          <Setter Property="VerticalAlignment" Value="Center" />
          <Setter Property="Template">
              <Setter.Value>
                  <ControlTemplate TargetType="ProgressBar">
                      <Grid>
                          <VisualStateManager.VisualStateGroups>
                              <VisualStateGroup x:Name="CommonStates">
                                  <VisualStateGroup.Transitions>
                                      <VisualTransition From="Updating" To="Determinate">
                                          <Storyboard>
                                              <RepositionThemeAnimation TargetName="ProgressBarIndicator" FromHorizontalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.IndicatorLengthDelta}" />
                                          </Storyboard>
                                      </VisualTransition>
                                      <VisualTransition From="Paused" To="Determinate">
                                          <Storyboard>
                                              <DoubleAnimation Storyboard.TargetName="ProgressBarIndicator"
                                                               Storyboard.TargetProperty="Opacity"
                                                               To="1"
                                                               Duration="0:0:0.25" />
                                          </Storyboard>
                                      </VisualTransition>
                                      <VisualTransition From="Indeterminate">
                                          <Storyboard>
                                              <FadeInThemeAnimation TargetName="EllipseGrid" />
                                          </Storyboard>
                                      </VisualTransition>
                                  </VisualStateGroup.Transitions>
                                  <VisualState x:Name="Determinate" />
                                  <VisualState x:Name="Updating" />
                                  <VisualState x:Name="Indeterminate">
                                      <Storyboard RepeatBehavior="Forever">
                                          <DoubleAnimation Storyboard.TargetName="EllipseGrid"
                                                           Duration="0:0:3.917"
                                                           Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
                                                           From="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ContainerAnimationStartPosition}"
                                                           To="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ContainerAnimationEndPosition}" />
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="E1">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:1" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" KeySpline="0.4,0,0.6,1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:3" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationEndPosition}" KeySpline="0.4,0,0.6,1" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="E2">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.167" Value="0" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:1.167" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" KeySpline="0.4,0,0.6,1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2.167" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:3.167" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationEndPosition}" KeySpline="0.4,0,0.6,1" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="E3">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.333" Value="0" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:1.333" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" KeySpline="0.4,0,0.6,1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2.333" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:3.333" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationEndPosition}" KeySpline="0.4,0,0.6,1" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="E4">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:1.5" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" KeySpline="0.4,0,0.6,1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2.5" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:3.5" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationEndPosition}" KeySpline="0.4,0,0.6,1" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="E5">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.667" Value="0" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:1.667" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" KeySpline="0.4,0,0.6,1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2.667" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationWellPosition}" />
                                              <SplineDoubleKeyFrame KeyTime="0:0:3.667" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseAnimationEndPosition}" KeySpline="0.4,0,0.6,1" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="B1">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="-50" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3" Value="100" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="B2">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="-50" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.667" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2.167" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.167" Value="100" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="B3">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="-50" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.833" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2.333" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.333" Value="100" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="B4">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="-50" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2.5" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.5" Value="100" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="B5">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="-50" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:1.167" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:2.667" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.667" Value="100" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimation Storyboard.TargetName="EllipseGrid"
                                                           Storyboard.TargetProperty="Opacity"
                                                           To="1"
                                                           Duration="0" />
                                          <ObjectAnimationUsingKeyFrames Storyboard.TargetName="E1"
                                                                        Storyboard.TargetProperty="Fill">
                                             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ProgressBarIndeterminateForegroundThemeBrush}" />
                                          </ObjectAnimationUsingKeyFrames>
                                          <ObjectAnimationUsingKeyFrames Storyboard.TargetName="E2"
                                                                        Storyboard.TargetProperty="Fill">
                                             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ProgressBarIndeterminateForegroundThemeBrush}" />
                                          </ObjectAnimationUsingKeyFrames>
                                          <ObjectAnimationUsingKeyFrames Storyboard.TargetName="E3"
                                                                        Storyboard.TargetProperty="Fill">
                                             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ProgressBarIndeterminateForegroundThemeBrush}" />
                                          </ObjectAnimationUsingKeyFrames>
                                          <ObjectAnimationUsingKeyFrames Storyboard.TargetName="E4"
                                                                        Storyboard.TargetProperty="Fill">
                                             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ProgressBarIndeterminateForegroundThemeBrush}" />
                                          </ObjectAnimationUsingKeyFrames>
                                          <ObjectAnimationUsingKeyFrames Storyboard.TargetName="E5"
                                                                        Storyboard.TargetProperty="Fill">
                                             <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ProgressBarIndeterminateForegroundThemeBrush}" />
                                          </ObjectAnimationUsingKeyFrames>
                                          <!-- Both FadeOutThemeAnimation and a DoubleAnimation on Opacity are necessary
                                               here.  The FadeOutThemeAnimation is necessary in the Indeterminate state so
                                               that we can do a FadeInThemeAnimation when transitioning back to the
                                               Determinate state.  The DoubleAnimation on Opacity is necessary to hide the
                                               DeterminateRoot immediately so that it does not slowly fade out during each
                                               iteration of the Indeterminate state animation. -->
                                          <FadeOutThemeAnimation TargetName="DeterminateRoot" />
                                          <DoubleAnimation Storyboard.TargetName="DeterminateRoot"
                                                           Storyboard.TargetProperty="Opacity"
                                                           To="0"
                                                           Duration="0" />
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E1">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3" Value="0" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E2">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.167" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.167" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.167" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.167" Value="0" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E3">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.333" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.333" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.333" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.333" Value="0" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E4">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.5" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.5" Value="0" />
                                          </DoubleAnimationUsingKeyFrames>
                                          <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="E5">
                                              <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.667" Value="0" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:0.667" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.667" Value="1" />
                                              <EasingDoubleKeyFrame KeyTime="0:0:3.667" Value="0" />
                                          </DoubleAnimationUsingKeyFrames>
                                      </Storyboard>
                                  </VisualState>
                                  <VisualState x:Name="Error">
                                      <Storyboard>
                                          <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ProgressBarIndicator">
                                              <DiscreteObjectKeyFrame KeyTime="0" Value="0" />
                                          </ObjectAnimationUsingKeyFrames>
                                      </Storyboard>
                                  </VisualState>
                                  <VisualState x:Name="Paused">
                                      <Storyboard>
                                          <DoubleAnimation Storyboard.TargetName="ProgressBarIndicator"
                                                           Storyboard.TargetProperty="Opacity"
                                                           To="0.5"
                                                           Duration="0:0:0.25" />
                                      </Storyboard>
                                  </VisualState>
                              </VisualStateGroup>
                          </VisualStateManager.VisualStateGroups>
                          <Grid x:Name="EllipseGrid"
                                Opacity="0">
                              <Grid.RenderTransform>
                                  <TranslateTransform />
                              </Grid.RenderTransform>
                              <Grid.ColumnDefinitions>
                                  <ColumnDefinition Width="Auto" />
                                  <ColumnDefinition Width="Auto" />
                                  <ColumnDefinition Width="Auto" />
                                  <ColumnDefinition Width="Auto" />
                                  <ColumnDefinition Width="Auto" />
                                  <ColumnDefinition Width="Auto" />
                                  <ColumnDefinition Width="Auto" />
                                  <ColumnDefinition Width="Auto" />
                                  <ColumnDefinition Width="Auto" />
                              </Grid.ColumnDefinitions>
                              <Border x:Name="B1"
                                      Grid.Column="8"
                                      RenderTransformOrigin="0.5,0.5">
                                  <Border.RenderTransform>
                                      <TranslateTransform />
                                  </Border.RenderTransform>
                                  <Ellipse x:Name="E1"
                                           Fill="{TemplateBinding Foreground}"
                                           Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           RenderTransformOrigin="0.5,0.5">
                                      <Ellipse.RenderTransform>
                                          <TranslateTransform />
                                      </Ellipse.RenderTransform>
                                  </Ellipse>
                              </Border>
                              <Rectangle Grid.Column="7"
                                         Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseOffset}" />
                              <Border x:Name="B2"
                                      Grid.Column="6"
                                      RenderTransformOrigin="0.5,0.5">
                                  <Border.RenderTransform>
                                      <TranslateTransform />
                                  </Border.RenderTransform>
                                  <Ellipse x:Name="E2"
                                           Fill="{TemplateBinding Foreground}"
                                           Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           RenderTransformOrigin="0.5,0.5">
                                      <Ellipse.RenderTransform>
                                          <TranslateTransform />
                                      </Ellipse.RenderTransform>
                                  </Ellipse>
                              </Border>
                              <Rectangle Grid.Column="5"
                                         Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseOffset}" />
                              <Border x:Name="B3"
                                      Grid.Column="4"
                                      RenderTransformOrigin="0.5,0.5">
                                  <Border.RenderTransform>
                                      <TranslateTransform />
                                  </Border.RenderTransform>
                                  <Ellipse x:Name="E3"
                                           Fill="{TemplateBinding Foreground}"
                                           Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           RenderTransformOrigin="0.5,0.5">
                                      <Ellipse.RenderTransform>
                                          <TranslateTransform />
                                      </Ellipse.RenderTransform>
                                  </Ellipse>
                              </Border>
                              <Rectangle Grid.Column="3"
                                         Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseOffset}" />
                              <Border x:Name="B4"
                                      Grid.Column="2"
                                      RenderTransformOrigin="0.5,0.5">
                                  <Border.RenderTransform>
                                      <TranslateTransform />
                                  </Border.RenderTransform>
                                  <Ellipse x:Name="E4"
                                           Fill="{TemplateBinding Foreground}"
                                           Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           RenderTransformOrigin="0.5,0.5">
                                      <Ellipse.RenderTransform>
                                          <TranslateTransform />
                                      </Ellipse.RenderTransform>
                                  </Ellipse>
                              </Border>
                              <Rectangle Grid.Column="1"
                                         Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseOffset}" />
                              <Border x:Name="B5"
                                      Grid.Column="0"
                                      RenderTransformOrigin="0.5,0.5">
                                  <Border.RenderTransform>
                                      <TranslateTransform />
                                  </Border.RenderTransform>
                                  <Ellipse x:Name="E5"
                                           Fill="{TemplateBinding Foreground}"
                                           Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.EllipseDiameter}"
                                           RenderTransformOrigin="0.5,0.5">
                                      <Ellipse.RenderTransform>
                                          <TranslateTransform />
                                      </Ellipse.RenderTransform>
                                  </Ellipse>
                              </Border>
                          </Grid>
                          <Border x:Name="DeterminateRoot"
                                  Background="{TemplateBinding Background}"
                                  BorderBrush="{TemplateBinding BorderBrush}"
                                  BorderThickness="{TemplateBinding BorderThickness}">
                              <Rectangle x:Name="ProgressBarIndicator"
                                         Margin="{TemplateBinding Padding}"
                                         Fill="{TemplateBinding Foreground}"
                                         HorizontalAlignment="Left" />
                          </Border>
                      </Grid>
                  </ControlTemplate>
              </Setter.Value>
          </Setter>
      </Style>
      

      【讨论】:

        猜你喜欢
        • 2018-04-07
        • 2012-11-08
        • 2018-01-01
        • 2023-04-07
        • 2016-01-30
        • 1970-01-01
        • 1970-01-01
        • 2011-06-08
        • 1970-01-01
        相关资源
        最近更新 更多