-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
MainWindow.xaml
415 lines (392 loc) · 23.4 KB
/
MainWindow.xaml
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<mah:MetroWindow x:Class="MetroDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controlzEx="urn:controlzex"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:exampleViews="clr-namespace:MetroDemo.ExampleViews"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:local="clr-namespace:MetroDemo"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MahApps.Metro - Demo Application"
Width="1024"
Height="768"
MinWidth="800"
MinHeight="600"
d:DataContext="{d:DesignInstance local:MainWindowViewModel}"
d:DesignHeight="600"
d:DesignWidth="800"
mah:DialogParticipation.Register="{Binding}"
Closing="MetroWindow_Closing"
GlowColor="{DynamicResource MahApps.Colors.Accent}"
Icon="mahapps.metro.logo2.ico"
NonActiveGlowColor="#CDFF0000"
ResizeMode="CanResizeWithGrip"
ShowIconOnTitleBar="True"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<!--
if using DialogParticipation on Windows which open/close frequently you will get a
memory leak unless you unregister. The easiest way to do this is in your Closing/Unloaded
event, as so:
DialogParticipation.SetRegister(this, null);
-->
<Window.Resources>
<ResourceDictionary>
<ObjectDataProvider x:Key="SyncModePreferenceEnumValues"
MethodName="GetValues"
ObjectType="{x:Type controlzEx:ThemeSyncMode}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="controlzEx:ThemeSyncMode" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<Ellipse x:Key="AppThemeMenuIcon"
Width="16"
Height="16"
x:Shared="False"
Fill="{Binding ColorBrush, Mode=OneWay}"
Stroke="{Binding BorderColorBrush, Mode=OneWay}"
StrokeThickness="1" />
<Ellipse x:Key="AccentMenuIcon"
Width="16"
Height="16"
x:Shared="False"
Fill="{Binding ColorBrush, Mode=OneWay}" />
<Style x:Key="AppThemeMenuItemStyle"
BasedOn="{StaticResource MahApps.Styles.MenuItem}"
TargetType="{x:Type MenuItem}">
<Setter Property="Command" Value="{Binding ChangeAccentCommand}" />
<Setter Property="CommandParameter" Value="{Binding Name, Mode=OneWay}" />
<Setter Property="Header" Value="{Binding Name, Mode=OneWay}" />
<Setter Property="Icon" Value="{StaticResource AppThemeMenuIcon}" />
</Style>
<Style x:Key="AccentColorMenuItemStyle"
BasedOn="{StaticResource MahApps.Styles.MenuItem}"
TargetType="{x:Type MenuItem}">
<Setter Property="Command" Value="{Binding ChangeAccentCommand}" />
<Setter Property="CommandParameter" Value="{Binding Name, Mode=OneWay}" />
<Setter Property="Header" Value="{Binding Name, Mode=OneWay}" />
<Setter Property="Icon" Value="{StaticResource AccentMenuIcon}" />
</Style>
<Style x:Key="SyncModeMenuItemStyle"
BasedOn="{StaticResource MahApps.Styles.MenuItem}"
TargetType="{x:Type MenuItem}">
<Setter Property="Command" Value="{Binding DataContext.ChangeSyncModeCommand, RelativeSource={RelativeSource AncestorType=Window}}" />
<Setter Property="CommandParameter" Value="{Binding Mode=OneTime}" />
<Setter Property="Header" Value="{Binding Mode=OneTime}" />
</Style>
<UserControl x:Key="CustomDialogTest"
x:Name="CustomDialogTest"
MinHeight="200">
<TextBlock x:Name="MessageTextBlock" Text="Message shown by this custom Dialog." />
</UserControl>
<UserControl x:Key="CustomCloseDialogTest" x:Name="CustomCloseDialogTest">
<StackPanel>
<TextBlock Height="30"
Margin="0 4"
Text="This dialog allows arbitrary content. You have to close it yourself by clicking the close button below."
TextWrapping="Wrap" />
<Button Margin="0 2"
Click="ShowSecondCustomDialog"
Content="Second Dialog"
Style="{DynamicResource MahApps.Styles.Button.Dialogs}" />
<Button Margin="0 2"
Click="CloseCustomDialog"
Content="Close Me!"
Style="{DynamicResource MahApps.Styles.Button.Dialogs}" />
</StackPanel>
</UserControl>
<ObjectDataProvider x:Key="CornerPreferenceEnumValues"
MethodName="GetValues"
ObjectType="{x:Type controlzEx:WindowCornerPreference}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="controlzEx:WindowCornerPreference" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="WindowBackdropTypeEnumValues"
MethodName="GetValues"
ObjectType="{x:Type controlzEx:WindowBackdropType}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="controlzEx:WindowBackdropType" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</ResourceDictionary>
</Window.Resources>
<mah:MetroWindow.LeftWindowCommands>
<mah:WindowCommands>
<Button Click="LaunchMahAppsOnGitHub" ToolTip="MahApps.Metro on GitHub">
<iconPacks:PackIconModern Width="22"
Height="22"
Kind="SocialGithubOctocat" />
</Button>
</mah:WindowCommands>
</mah:MetroWindow.LeftWindowCommands>
<mah:MetroWindow.RightWindowCommands>
<mah:WindowCommands ShowLastSeparator="False">
<Button Click="LaunchFlyoutDemo"
Content="Flyouts"
ToolTip="Flyouts demo window" />
<Button Click="LaunchIcons"
Content="IconPacks"
ToolTip="All MahApp icons" />
<Button Click="LaunchVisualStudioDemo"
Content="VS"
ToolTip="Visual Studio style demo" />
<Button Click="LauchCleanDemo"
Content="Clean"
ToolTip="Clean window style demo" />
<Button Click="InteropDemo"
Content="Interop"
ToolTip="The interop demo" />
<Button Click="LaunchNavigationDemo"
Content="Navigation"
ToolTip="Window navigation demo" />
<ToggleButton Content="Confirm quit"
IsChecked="{Binding QuitConfirmationEnabled}"
ToolTip="Enable quit confirmation dialog on exit" />
</mah:WindowCommands>
</mah:MetroWindow.RightWindowCommands>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Menu Grid.Row="0"
Margin="5"
HorizontalAlignment="Left"
VerticalAlignment="Stretch">
<MenuItem Header="Theme"
ItemContainerStyle="{StaticResource AppThemeMenuItemStyle}"
ItemsSource="{Binding AppThemes, Mode=OneWay}" />
<MenuItem Header="Accent"
ItemContainerStyle="{StaticResource AccentColorMenuItemStyle}"
ItemsSource="{Binding AccentColors, Mode=OneWay}" />
<MenuItem Header="ThemeManager">
<MenuItem Header="SyncMode"
ItemContainerStyle="{StaticResource SyncModeMenuItemStyle}"
ItemsSource="{Binding Source={StaticResource SyncModePreferenceEnumValues}}" />
<MenuItem Header="Use HSL colors?"
IsCheckable="True"
IsChecked="{Binding Options.UseHSL, Source={x:Static controlzEx:RuntimeThemeGenerator.Current}, Mode=TwoWay}" />
<MenuItem Command="{Binding DataContext.SyncThemeNowCommand, RelativeSource={RelativeSource AncestorType=Window}}" Header="Sync now" />
</MenuItem>
<MenuItem Header="Dialogs">
<MenuItem Header="Use Accent?"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=UseAccentForDialogs}" />
<MenuItem Header="Use Invert?"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=UseInvertForDialogs}" />
<MenuItem Header="Show Icon?"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=ShowIconOnDialogs}" />
<MenuItem Header="Show Dialogs over TitleBar"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=ShowDialogsOverTitleBar}" />
<Separator />
<MenuItem Click="ShowInputDialog" Header="Show InputDialog" />
<MenuItem Click="ShowInputDialogCustomButtonSizes" Header="Show InputDialog (with custom button font sizes)" />
<MenuItem Click="ShowLoginDialog" Header="Show LoginDialog" />
<MenuItem Click="ShowLoginDialogPasswordPreview" Header="Show Password Preview LoginDialog" />
<MenuItem Click="ShowLoginDialogOnlyPassword" Header="Show LoginDialog (Only Password)" />
<MenuItem Click="ShowLoginDialogWithRememberCheckBox" Header="Show LoginDialog (With Remember CheckBox)" />
<MenuItem Click="ShowMessageDialog" Header="Show MessageDialog" />
<MenuItem Click="ShowLimitedMessageDialog" Header="Show MessageDialog (Limited Size)" />
<MenuItem Click="ShowProgressDialog" Header="Show ProgressDialog" />
<MenuItem Click="ShowCustomDialog" Header="Show CustomDialog" />
<MenuItem Click="ShowAwaitCustomDialog" Header="Await CustomDialog" />
<Separator />
<MenuItem Click="ShowInputDialogOutside" Header="Show ShowInputDialog Externally" />
<MenuItem Click="ShowLoginDialogOutside" Header="Show ShowLoginDialog Externally" />
<MenuItem Click="ShowMessageDialogOutside" Header="Show ShowMessageDialog Externally" />
<Separator />
<MenuItem Command="{Binding ShowInputDialogCommand}" Header="Show InputDialog via VM" />
<MenuItem Command="{Binding ShowLoginDialogCommand}" Header="Show LoginDialog via VM ..." />
<MenuItem Header="Show MessageDialog via VM">
<MenuItem Command="{Binding ShowMessageDialogCommand}"
CommandParameter="DISPATCHER_THREAD"
Header="... from Main Thread" />
<MenuItem Command="{Binding ShowMessageDialogCommand}"
CommandParameter="BACKGROUND_THREAD"
Header="... from Background Thread" />
</MenuItem>
<MenuItem Command="{Binding ShowProgressDialogCommand}" Header="Show ProgressDialog via VM" />
<MenuItem Command="{Binding ShowCustomDialogCommand}" Header="Show CustomDialog via VM" />
</MenuItem>
<MenuItem Header="Window">
<MenuItem Header="Chrome">
<MenuItem>
<MenuItem.Template>
<ControlTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="CornerPreference" />
<ComboBox VerticalAlignment="Center"
ItemsSource="{Binding Source={StaticResource CornerPreferenceEnumValues}}"
SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=CornerPreference, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ControlTemplate>
</MenuItem.Template>
</MenuItem>
<MenuItem>
<MenuItem.Template>
<ControlTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="Backdrop" />
<ComboBox VerticalAlignment="Center"
ItemsSource="{Binding Source={StaticResource WindowBackdropTypeEnumValues}}"
SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=(controlzEx:WindowBackdropManager.BackdropType), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ControlTemplate>
</MenuItem.Template>
</MenuItem>
</MenuItem>
<MenuItem Header="Glow">
<MenuItem Header="PreferDWMBorderColor"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=PreferDWMBorderColor}" />
<MenuItem Header="DWMSupportsBorderColor"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=DWMSupportsBorderColor}"
IsEnabled="False" />
</MenuItem>
<MenuItem Header="ShowTitleBar"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=ShowTitleBar}" />
<MenuItem Header="ShowInTaskbar"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=ShowInTaskbar}" />
<MenuItem Header="Topmost"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=Topmost}" />
<MenuItem Header="Ignore taskbar on maximize"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=IgnoreTaskbarOnMaximize}" />
<MenuItem Header="Toggle FullScreen (no taskbar, window style = none)"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=ToggleFullScreen}" />
<Separator />
<MenuItem Click="MenuWindowWithGlowOnClick" Header="Window with Glow" />
<MenuItem Click="MenuWindowWithoutGlowOnClick" Header="Window without Glow" />
<MenuItem Click="MenuWindowWithBorderOnClick" Header="Window with Border (and Glow)" />
<MenuItem Click="MenuWindowWithRoundedBorderOnClick" Header="Window with rounded Border (without Glow)" />
<MenuItem Click="LaunchSizeToContentDemo" Header="Window with SizeToContent" />
<Separator />
<MenuItem x:Name="ShowSeparatorsMI"
Header="ShowSeparators (RightWindowCommands)"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=RightWindowCommands.ShowSeparators}" />
<MenuItem Header="ShowLastSeparator in (RightWindowCommands)"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=RightWindowCommands.ShowLastSeparator}"
IsEnabled="{Binding ElementName=ShowSeparatorsMI, Path=IsChecked, Mode=OneWay}" />
<Separator />
<MenuItem Command="{Binding ToggleIconScalingCommand}"
CommandParameter="{x:Static mah:MultiFrameImageMode.ScaleDownLargerFrame}"
Header="Window icon: scale down larger frame"
IsCheckable="True"
IsChecked="{Binding IsScaleDownLargerFrame, Mode=OneWay}" />
<MenuItem Command="{Binding ToggleIconScalingCommand}"
CommandParameter="{x:Static mah:MultiFrameImageMode.NoScaleSmallerFrame}"
Header="Window icon: no scale, smaller frame"
IsCheckable="True"
IsChecked="{Binding IsNoScaleSmallerFrame, Mode=OneWay}" />
<Separator />
<MenuItem Header="ShowSystemMenu"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=ShowSystemMenu}" />
<MenuItem Header="ShowSystemMenuOnRightClick"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mah:MetroWindow}}, Path=ShowSystemMenuOnRightClick}" />
</MenuItem>
</Menu>
<mah:MetroAnimatedSingleRowTabControl x:Name="MainTabControl" Grid.Row="1">
<TabItem Header="buttons">
<ScrollViewer Margin="2"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<exampleViews:ButtonsExample DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
<TabItem Header="text">
<ScrollViewer Margin="2"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<exampleViews:TextExamples DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
<TabItem Header="dates">
<ScrollViewer Margin="2"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<exampleViews:DateExamples DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
<TabItem Header="selection">
<exampleViews:SelectionExamples DataContext="{Binding}" />
</TabItem>
<TabItem Header="sliders">
<ScrollViewer Margin="2"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<exampleViews:Sliders DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
<TabItem Header="progress">
<ScrollViewer Margin="2"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<exampleViews:ProgressBars DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
<TabItem Header="splitview">
<ScrollViewer Margin="2" VerticalScrollBarVisibility="Auto">
<exampleViews:SplitViewExamples DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
<TabItem Header="hamburger">
<exampleViews:HamburgerMenuSample DataContext="{Binding}" />
</TabItem>
<TabItem Header="tabcontrol">
<ScrollViewer Margin="2"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<exampleViews:TabControlExamples DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
<TabItem Header="datagrid">
<exampleViews:DataGridExamples DataContext="{Binding}" />
</TabItem>
<TabItem Header="tiles">
<ScrollViewer Margin="2"
mah:ScrollViewerHelper.IsHorizontalScrollWheelEnabled="True"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Disabled">
<exampleViews:TilesExample DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
<TabItem Header="colors">
<exampleViews:ColorExample Margin="2" DataContext="{Binding}" />
</TabItem>
<TabItem Header="ColorPicker">
<exampleViews:ColorPickerExample />
</TabItem>
<TabItem Header="MultiSelectionComboBox">
<exampleViews:MultiSelectionComboBoxExample />
</TabItem>
<TabItem Header="others">
<ScrollViewer Margin="2"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<exampleViews:OtherExamples DataContext="{Binding}" />
</ScrollViewer>
</TabItem>
</mah:MetroAnimatedSingleRowTabControl>
<StatusBar Grid.Row="2">
<StatusBarItem>MahApps.Metro DEMO Application</StatusBarItem>
<Separator Style="{StaticResource MahApps.Styles.Separator.StatusBar}" />
<StatusBarItem>Selected Tab:</StatusBarItem>
<StatusBarItem Content="{Binding ElementName=MainTabControl, Path=SelectedItem.Header, Mode=OneWay}" />
</StatusBar>
</Grid>
</mah:MetroWindow>