2015-03-20 3 views

ответ

1

Я надеюсь, что следующий стиль является хорошей отправной точкой. Я оставляю это вам, чтобы создать зеленые клещи (Фон первого прямоугольника VisualBrush).

<Style TargetType="{x:Type ProgressBar}"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type ProgressBar}"> 
        <Grid> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Determinate" /> 
           <VisualState x:Name="Indeterminate"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Duration="00:00:00" 
                     Storyboard.TargetName="PART_Indicator" 
                     Storyboard.TargetProperty="Background"> 
              <DiscreteObjectKeyFrame KeyTime="00:00:00"> 
               <DiscreteObjectKeyFrame.Value> 
                <SolidColorBrush>Transparent</SolidColorBrush> 
               </DiscreteObjectKeyFrame.Value> 
              </DiscreteObjectKeyFrame> 
             </ObjectAnimationUsingKeyFrames> 
             <ColorAnimationUsingKeyFrames Storyboard.TargetName="PART_GlowRect" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"> 
              <EasingColorKeyFrame KeyTime="0" Value="#00FFFFFF" /> 
             </ColorAnimationUsingKeyFrames> 
             <ColorAnimationUsingKeyFrames Storyboard.TargetName="PART_GlowRect" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)"> 
              <EasingColorKeyFrame KeyTime="0" Value="#00FFFFFF" /> 
             </ColorAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Border x:Name="PART_Track" 
           Background="White" 
           BorderBrush="#FFDEDEDE" 
           BorderThickness="2" 
           ClipToBounds="True" 
           CornerRadius="3"> 
          <Border x:Name="PART_Indicator" 
            Margin="4" 
            HorizontalAlignment="Left" 
            BorderThickness="0" 
            CornerRadius="0"> 
           <Border.Background> 
            <VisualBrush Stretch="None" 
               TileMode="Tile" 
               Viewbox="0,0,1.,1" 
               ViewboxUnits="RelativeToBoundingBox" 
               Viewport="0,0,30,30" 
               ViewportUnits="Absolute"> 
             <VisualBrush.Visual> 
              <StackPanel Orientation="Horizontal"> 
               <Rectangle Width="30" 
                  Height="30" 
                  Fill="#FF23FF00" /> 
               <Rectangle Width="10" 
                  Height="30" 
                  Fill="Transparent" /> 
              </StackPanel> 
             </VisualBrush.Visual> 
            </VisualBrush> 
           </Border.Background> 

           <Grid x:Name="Animation" ClipToBounds="True"> 
            <Border x:Name="PART_GlowRect" 
              Width="100" 
              Margin="-100,0,0,0" 
              HorizontalAlignment="Left" 
              VerticalAlignment="Stretch" 
              CornerRadius="0"> 
             <Border.Background> 
              <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5"> 
               <GradientStop Offset="0" Color="#00E8DF2E" /> 
               <GradientStop Offset="0.4" Color="#FF38E41D" /> 
               <GradientStop Offset="0.6" Color="#FF38E41D" /> 
               <GradientStop Offset="1" Color="#00E8DF2E" /> 
              </LinearGradientBrush> 
             </Border.Background> 
            </Border> 
           </Grid> 
          </Border> 
         </Border> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
+0

Спасибо. Хотелось бы, чтобы я знал, как прогресс управляет PART_Indicator ... он меняет свой размер? Например, какой прогрессбар делает, когда я устанавливаю значение = 50 и максимум = 100? – JobaDiniz

+0

Вправо: изменяется размер элемента PART_Indicator. Кодировка прокрутки позади делает это в зависимости от заданных настроек. – gomi42

Смежные вопросы