-
-
Save sphingu/5781057 to your computer and use it in GitHub Desktop.
Processbar Style in WPF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.xaml in Root folder of project | |
<Application> | |
<Application.Resources> | |
<ResourceDictionary> | |
<ResourceDictionary.MergedDictionaries> | |
<ResourceDictionary Source="/ProcessStyle.xaml"/> | |
</ResourceDictionary.mergedDictionaries> | |
</ResourceDictionary> | |
</Application.Resources> | |
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add Resource Dictionary File your project like 'ProcessStyle.xaml' | |
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | |
<LinearGradientBrush x:Key="ProgressBarBackground" EndPoint="1,0" StartPoint="0,0"> | |
<GradientStop Color="#BABABA" Offset="0"/> | |
<GradientStop Color="#C7C7C7" Offset="0.5"/> | |
<GradientStop Color="#BABABA" Offset="1"/> | |
</LinearGradientBrush> | |
<LinearGradientBrush x:Key="ProgressBarBorderBrush" EndPoint="0,1" StartPoint="0,0"> | |
<GradientStop Color="#B2B2B2" Offset="0"/> | |
<GradientStop Color="#8C8C8C" Offset="1"/> | |
</LinearGradientBrush> | |
<LinearGradientBrush x:Key="ProgressBarGlassyHighlight" EndPoint="0,1" StartPoint="0,0"> | |
<GradientStop Color="#50FFFFFF" Offset="0.5385"/> | |
<GradientStop Color="#00FFFFFF" Offset="0.5385"/> | |
</LinearGradientBrush> | |
<LinearGradientBrush x:Key="ProgressBarTopHighlight" EndPoint="0,1" StartPoint="0,0"> | |
<GradientStop Color="#80FFFFFF" Offset="0.05"/> | |
<GradientStop Color="#00FFFFFF" Offset="0.25"/> | |
</LinearGradientBrush> | |
<LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill" EndPoint="1,0" StartPoint="0,0"> | |
<GradientStop Color="#00FFFFFF" Offset="0"/> | |
<GradientStop Color="#60FFFFFF" Offset="0.4"/> | |
<GradientStop Color="#60FFFFFF" Offset="0.6"/> | |
<GradientStop Color="#00FFFFFF" Offset="1"/> | |
</LinearGradientBrush> | |
<LinearGradientBrush x:Key="ProgressBarIndicatorDarkEdgeLeft" EndPoint="1,0" StartPoint="0,0"> | |
<GradientStop Color="#0C000000" Offset="0"/> | |
<GradientStop Color="#20000000" Offset="0.3"/> | |
<GradientStop Color="#00000000" Offset="1"/> | |
</LinearGradientBrush> | |
<LinearGradientBrush x:Key="ProgressBarIndicatorDarkEdgeRight" EndPoint="1,0" StartPoint="0,0"> | |
<GradientStop Color="#00000000" Offset="0"/> | |
<GradientStop Color="#20000000" Offset="0.7"/> | |
<GradientStop Color="#0C000000" Offset="1"/> | |
</LinearGradientBrush> | |
<RadialGradientBrush x:Key="ProgressBarIndicatorLightingEffectLeft" RadiusY="1" RadiusX="1" RelativeTransform="1,0,0,1,0.5,0.5"> | |
<GradientStop Color="#60FFFFC4" Offset="0"/> | |
<GradientStop Color="#00FFFFC4" Offset="1"/> | |
</RadialGradientBrush> | |
<LinearGradientBrush x:Key="ProgressBarIndicatorLightingEffect" EndPoint="0,0" StartPoint="0,1"> | |
<GradientStop Color="#60FFFFC4" Offset="0"/> | |
<GradientStop Color="#00FFFFC4" Offset="1"/> | |
</LinearGradientBrush> | |
<RadialGradientBrush x:Key="ProgressBarIndicatorLightingEffectRight" RadiusY="1" RadiusX="1" RelativeTransform="1,0,0,1,-0.5,0.5"> | |
<GradientStop Color="#60FFFFC4" Offset="0"/> | |
<GradientStop Color="#00FFFFC4" Offset="1"/> | |
</RadialGradientBrush> | |
<LinearGradientBrush x:Key="ProgressBarIndicatorGlassyHighlight" EndPoint="0,1" StartPoint="0,0"> | |
<GradientStop Color="#90FFFFFF" Offset="0.5385"/> | |
<GradientStop Color="#00FFFFFF" Offset="0.5385"/> | |
</LinearGradientBrush> | |
<Style x:Key="ProgressBarTestStyle" TargetType="{x:Type ProgressBar}"> | |
<Setter Property="Foreground" Value="#FF0699D6"/> | |
<Setter Property="Background" Value="{StaticResource ProgressBarBackground}"/> | |
<Setter Property="BorderBrush" Value="{StaticResource ProgressBarBorderBrush}"/> | |
<Setter Property="BorderThickness" Value="1"/> | |
<Setter Property="Template"> | |
<Setter.Value> | |
<ControlTemplate TargetType="{x:Type ProgressBar}"> | |
<Grid x:Name="TemplateRoot" SnapsToDevicePixels="true"> | |
<Rectangle Fill="{TemplateBinding Background}" RadiusY="2" RadiusX="2"/> | |
<Border Background="{StaticResource ProgressBarGlassyHighlight}" CornerRadius="2" Margin="1"/> | |
<Border BorderBrush="#80FFFFFF" BorderThickness="1,0,1,1" Background="{StaticResource ProgressBarTopHighlight}" Margin="1"/> | |
<Rectangle x:Name="PART_Track" Margin="1"/> | |
<Decorator x:Name="PART_Indicator" HorizontalAlignment="Left" Margin="1"> | |
<Grid x:Name="Foreground" Background="{x:Null}"> | |
<Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/> | |
<Grid x:Name="Animation" ClipToBounds="true"> | |
<Rectangle x:Name="PART_GlowRect" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}" HorizontalAlignment="Left" Margin="-100,0,0,0" Width="100"/> | |
</Grid> | |
<Grid x:Name="Overlay"> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition MaxWidth="15"/> | |
<ColumnDefinition Width="0.1*"/> | |
<ColumnDefinition MaxWidth="15"/> | |
</Grid.ColumnDefinitions> | |
<Grid.RowDefinitions> | |
<RowDefinition/> | |
<RowDefinition/> | |
</Grid.RowDefinitions> | |
<Rectangle x:Name="LeftDark" Margin="1,1,0,1" RadiusY="1" RadiusX="1" Grid.RowSpan="2"> | |
<Rectangle.Fill> | |
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0"> | |
<GradientStop Color="#0C000000" Offset="0"/> | |
<GradientStop Color="#20000000" Offset="0.3"/> | |
<GradientStop Offset="1"/> | |
</LinearGradientBrush> | |
</Rectangle.Fill> | |
</Rectangle> | |
<Rectangle x:Name="RightDark" Grid.Column="2" Margin="0,1,1,1" RadiusY="1" RadiusX="1" Grid.RowSpan="2"> | |
<Rectangle.Fill> | |
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0"> | |
<GradientStop Color="#00000000" Offset="0"/> | |
<GradientStop Color="#20000000" Offset="0.7"/> | |
<GradientStop Color="#0C000000" Offset="1"/> | |
</LinearGradientBrush> | |
</Rectangle.Fill> | |
</Rectangle> | |
<Rectangle x:Name="LeftLight" Grid.Column="0" Grid.Row="2"> | |
<Rectangle.Fill> | |
<RadialGradientBrush RadiusY="1" RadiusX="1" RelativeTransform="1,0,0,1,0.5,0.5"> | |
<GradientStop Color="#60C4CAFF" Offset="0.006"/> | |
<GradientStop Color="#00C4C8FF" Offset="1"/> | |
</RadialGradientBrush> | |
</Rectangle.Fill> | |
</Rectangle> | |
<Rectangle x:Name="CenterLight" Grid.Column="1" Grid.Row="2"> | |
<Rectangle.Fill> | |
<LinearGradientBrush EndPoint="0,0" StartPoint="0,1"> | |
<GradientStop Color="#60C4C8FF" Offset="0"/> | |
<GradientStop Color="#00C4C8FF" Offset="1"/> | |
</LinearGradientBrush> | |
</Rectangle.Fill> | |
</Rectangle> | |
<Rectangle x:Name="RightLight" Grid.Column="2" Grid.Row="2"> | |
<Rectangle.Fill> | |
<RadialGradientBrush RadiusY="1" RadiusX="1" RelativeTransform="1,0,0,1,-0.5,0.5"> | |
<GradientStop Color="#60C4C8FF" Offset="0"/> | |
<GradientStop Color="#00C4C8FF" Offset="1"/> | |
</RadialGradientBrush> | |
</Rectangle.Fill> | |
</Rectangle> | |
<Border x:Name="Highlight1" Grid.ColumnSpan="3" Grid.RowSpan="2"> | |
<Border.Background> | |
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> | |
<GradientStop Color="#90FFFFFF" Offset="0.5385"/> | |
<GradientStop Color="#00FFFFFF" Offset="0.5385"/> | |
</LinearGradientBrush> | |
</Border.Background> | |
</Border> | |
<Border x:Name="Highlight2" Grid.ColumnSpan="3" Grid.RowSpan="2"> | |
<Border.Background> | |
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> | |
<GradientStop Color="#80FFFFFF" Offset="0.05"/> | |
<GradientStop Color="#00FFFFFF" Offset="0.25"/> | |
</LinearGradientBrush> | |
</Border.Background> | |
</Border> | |
</Grid> | |
</Grid> | |
</Decorator> | |
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/> | |
</Grid> | |
<ControlTemplate.Triggers> | |
<Trigger Property="Orientation" Value="Vertical"> | |
<Setter Property="LayoutTransform" TargetName="TemplateRoot"> | |
<Setter.Value> | |
<RotateTransform Angle="-90"/> | |
</Setter.Value> | |
</Setter> | |
</Trigger> | |
<Trigger Property="IsIndeterminate" Value="true"> | |
<Setter Property="Visibility" TargetName="LeftDark" Value="Collapsed"/> | |
<Setter Property="Visibility" TargetName="RightDark" Value="Collapsed"/> | |
<Setter Property="Visibility" TargetName="LeftLight" Value="Collapsed"/> | |
<Setter Property="Visibility" TargetName="CenterLight" Value="Collapsed"/> | |
<Setter Property="Visibility" TargetName="RightLight" Value="Collapsed"/> | |
<Setter Property="Visibility" TargetName="Indicator" Value="Collapsed"/> | |
</Trigger> | |
<Trigger Property="IsIndeterminate" Value="false"> | |
<Setter Property="Background" TargetName="Animation" Value="#80B5FFA9"/> | |
</Trigger> | |
</ControlTemplate.Triggers> | |
</ControlTemplate> | |
</Setter.Value> | |
</Setter> | |
</Style> | |
</ResourceDictionary> | |
------------------------------------------------------------------------------ | |
//Add Process bar in any window of your project | |
------------------------------------------------------------------------------ | |
<ProgressBar Height="30" Width="400" Foreground="#00FF8F" Style="{DynamicResource ProgressBarTestStyle}" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment