1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
<UserControl x:Class="MaterialDesignColors.WpfExample.Progress"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- you only need bring this resource in if you want to specify the circular style statically -->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ProgressBar.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<smtx:XamlDisplay Key="progress_1" Margin="24" Grid.RowSpan="2">
<!-- linear progress bars (the default style -->
<ProgressBar Orientation="Vertical" Value="25" />
</smtx:XamlDisplay>
<smtx:XamlDisplay Key="progress_2" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Margin="24">
<ProgressBar Orientation="Vertical" Height="10" IsIndeterminate="True" />
</smtx:XamlDisplay>
<StackPanel Grid.Row="0" Grid.Column="2" HorizontalAlignment="Stretch">
<smtx:XamlDisplay Key="progress_3" Margin="24">
<ProgressBar Value="25" Height="10" />
</smtx:XamlDisplay>
<smtx:XamlDisplay Key="progress_4" Margin="24">
<ProgressBar Value="50" materialDesign:TransitionAssist.DisableTransitions="True" />
</smtx:XamlDisplay>
<smtx:XamlDisplay Key="progress_5" Margin="24">
<!-- should disable on 2nd transition... -->
<ProgressBar Value="75" />
</smtx:XamlDisplay>
<smtx:XamlDisplay Key="progress_6" Margin="24">
<ProgressBar IsIndeterminate="True" />
</smtx:XamlDisplay>
</StackPanel>
<!-- circular progress bars.. specify the MaterialDesignCicularProgressBar resource -->
<Grid VerticalAlignment="Top" Grid.Column="2" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.ColumnSpan="2" FontSize="16" TextWrapping="Wrap" TextAlignment="Center" HorizontalAlignment="Stretch"
Margin="0 0 0 16">
No extra control is required for the circular style, it is purely a standard ProgressBar, with the MaterialDesignCircularProgressBar style applied.
</TextBlock>
<smtx:XamlDisplay Key="progress_7" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="12">
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}"
x:Name="DeterminateCircularProgress"/>
</smtx:XamlDisplay>
<TextBlock Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" TextWrapping="Wrap">Standard deterministic progress bar, running from 0 to 100%.  For the purpose of the demo, a storyboard is used to animate the .Value property.</TextBlock>
<smtx:XamlDisplay Key="progress_8" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="12">
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}"
Value="35"
IsIndeterminate="True"/>
</smtx:XamlDisplay>
<TextBlock Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" TextWrapping="Wrap">Indeterminate progress bar, at 35%.</TextBlock>
<smtx:XamlDisplay Key="progress_9" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="12">
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}"
Value="0"
IsIndeterminate="True"/>
</smtx:XamlDisplay>
<TextBlock Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" TextWrapping="Wrap">Fully indeterminate progress bar, using .Value=0 to inform the theme.</TextBlock>
<smtx:XamlDisplay Key="progress_10" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="12">
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}"
Value="20"
IsIndeterminate="True"
x:Name="IndeterminateToDeterminateCircularProgress"/>
</smtx:XamlDisplay>
<TextBlock Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" TextWrapping="Wrap">An indeterminate job transitioning to a determinate job, completing to 100%.  For the purpose of the demo, a storyboard is used to animate the .Value and .IsIndeterminate properties.</TextBlock>
<smtx:XamlDisplay Key="progress_11" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="12">
<materialDesign:Card UniformCornerRadius="14" Padding="4">
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}"
Value="50"
IsIndeterminate="True" />
</materialDesign:Card>
</smtx:XamlDisplay>
<TextBlock Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" TextWrapping="Wrap">Wrap in a Card control to raise the material.</TextBlock>
<smtx:XamlDisplay Key="progress_12" Grid.Row="6" Grid.Column="0"
VerticalAlignment="Center" HorizontalAlignment="Center" Margin="12">
<materialDesign:Card UniformCornerRadius="14"
RenderTransformOrigin=".5,.5"
Padding="4">
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}"
x:Name="AnimatedProgressInCard" />
<materialDesign:Card.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="ScaleTransform" ScaleX="0" ScaleY="0" />
</TransformGroup>
</materialDesign:Card.RenderTransform>
<materialDesign:Card.Style>
<Style TargetType="materialDesign:Card" BasedOn="{StaticResource {x:Type materialDesign:Card}}">
<Style.Resources>
<Storyboard x:Key="FadeIn" FillBehavior="HoldEnd">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<EasingDoubleKeyFrame Value="0" />
<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.8">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<EasingDoubleKeyFrame Value="0" />
<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.8">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="FadeOut">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<EasingDoubleKeyFrame Value="1" />
<EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.8">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<EasingDoubleKeyFrame Value="1" />
<EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.8">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Style.Resources>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=AnimatedProgressInCard, Path=Value}" Value="20">
<DataTrigger.EnterActions>
<RemoveStoryboard BeginStoryboardName="FadeOut" />
<BeginStoryboard Storyboard="{StaticResource FadeIn}" Name="FadeIn" />
</DataTrigger.EnterActions>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=AnimatedProgressInCard, Path=Value}" Value="100">
<DataTrigger.EnterActions>
<RemoveStoryboard BeginStoryboardName="FadeIn" />
<BeginStoryboard Storyboard="{StaticResource FadeOut}" Name="FadeOut" />
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</materialDesign:Card.Style>
</materialDesign:Card>
</smtx:XamlDisplay>
<TextBlock Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" TextWrapping="Wrap">Apply some animations to the card to get funky!</TextBlock>
</Grid>
</Grid>
<!-- these animations are used to control the circular progress bars' values, so we don't need
code-behind or a view model to illustrate them in action
-->
<UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetName="DeterminateCircularProgress" TargetProperty="Value" RepeatBehavior="Forever" Duration="0:0:3">
<DoubleAnimation From="0" To="100" Duration="0:0:2.5" FillBehavior="Stop">
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard TargetName="IndeterminateToDeterminateCircularProgress" RepeatBehavior="Forever" Duration="0:0:9">
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsIndeterminate">
<DiscreteBooleanKeyFrame Value="False" KeyTime="0:0:4" />
</BooleanAnimationUsingKeyFrames>
<DoubleAnimation From="20" To="100" Duration="0:0:2.5" BeginTime="0:0:4"
Storyboard.TargetProperty="Value"
FillBehavior="HoldEnd">
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard TargetName="AnimatedProgressInCard" RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Value">
<DiscreteDoubleKeyFrame Value="0" KeyTime="0"/>
<DiscreteDoubleKeyFrame Value="1" KeyTime="0:0:0.1"/>
<!-- we have used a 20% startup to fade in on the actual control -->
<DiscreteDoubleKeyFrame Value="20" KeyTime="0:0:1"/>
<!-- pretend we are indeterminate for 4 seconds -->
<DiscreteDoubleKeyFrame Value="20" KeyTime="0:0:4"/>
<!-- now we become determinate and complete to 100% -->
<SplineDoubleKeyFrame Value="100" KeyTime="0:0:8"/>
<SplineDoubleKeyFrame Value="100" KeyTime="0:0:9"/>
</DoubleAnimationUsingKeyFrames>
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsIndeterminate" Duration="0:0:10">
<DiscreteBooleanKeyFrame Value="True" KeyTime="0:0:0.1" />
<DiscreteBooleanKeyFrame Value="True" KeyTime="0:0:3.9" />
<!-- now we become determinate and complete to 100% -->
<DiscreteBooleanKeyFrame Value="False" KeyTime="0:0:4" />
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</UserControl.Triggers>
</UserControl>
|