forked from MahApps/MahApps.Metro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlyoutDemo.xaml
532 lines (500 loc) · 25.2 KB
/
FlyoutDemo.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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
<Controls:MetroWindow x:Class="MetroDemo.ExampleWindows.FlyoutDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:exampleWindows="clr-namespace:MetroDemo.ExampleWindows"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:metroDemo="clr-namespace:MetroDemo"
x:Name="flyoutsDemo"
Title="Flyouts Demo"
Width="700"
Height="500"
MinWidth="700"
MinHeight="500"
d:DataContext="{d:DesignInstance metroDemo:MainWindowViewModel}"
BorderBrush="{DynamicResource MahApps.Brushes.Accent}"
BorderThickness="1"
IconOverlayBehavior="Never"
SaveWindowPosition="True"
TitleCharacterCasing="Normal"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ObjectDataProvider x:Key="WindowCommandsOverlayBehaviorValues"
MethodName="GetValues"
ObjectType="{x:Type Controls:WindowCommandsOverlayBehavior}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="Controls:WindowCommandsOverlayBehavior" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="OverlayBehaviorValues"
MethodName="GetValues"
ObjectType="{x:Type Controls:OverlayBehavior}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="Controls:OverlayBehavior" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</ResourceDictionary>
</Window.Resources>
<Controls:MetroWindow.IconTemplate>
<DataTemplate>
<iconPacks:PackIconModern Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Margin="4"
Foreground="{DynamicResource MahApps.Brushes.IdealForeground}"
Kind="Box" />
</DataTemplate>
</Controls:MetroWindow.IconTemplate>
<Controls:MetroWindow.TitleTemplate>
<DataTemplate>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock Margin="0 -1 8 0"
VerticalAlignment="Center"
FontFamily="{DynamicResource MahApps.Fonts.Family.Window.Title}"
FontSize="{DynamicResource MahApps.Font.Size.Window.Title}"
Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis" />
<Button Margin="1 0 1 1"
Click="ClickMeOnClick"
Content="Click Me..."
Style="{StaticResource MahApps.Styles.Button.Flat}" />
</StackPanel>
</DataTemplate>
</Controls:MetroWindow.TitleTemplate>
<Controls:MetroWindow.LeftWindowCommands>
<Controls:WindowCommands ShowSeparators="False">
<Button Content="A"
FontFamily="Wingdings"
FontSize="20" />
</Controls:WindowCommands>
</Controls:MetroWindow.LeftWindowCommands>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands>
<Button Content="B"
FontFamily="Wingdings"
FontSize="20" />
<Button Content="C"
FontFamily="Wingdings"
FontSize="20" />
</Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>
<Controls:MetroWindow.Flyouts>
<Controls:FlyoutsControl x:Name="flyoutsControl">
<Controls:Flyout x:Name="settingsFlyout"
Margin="200 30 0 0"
Controls:ControlsHelper.ContentCharacterCasing="Upper"
Controls:HeaderedControlHelper.HeaderFontFamily="Segoe Script"
AreAnimationsEnabled="True"
FocusedElement="{Binding ElementName=firstTB}"
Header="Settings"
Position="Right">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<TextBlock Grid.Row="0" Text="Something above the ScrollPanel" />
<TextBlock Grid.Row="0" Text="This Flyout animates its opacity when opening and closing." />
</StackPanel>
<TabControl Grid.Row="1" Controls:TabControlHelper.Underlined="TabPanel">
<TabItem Header="Settings">
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<TextBox x:Name="firstTB" Controls:TextBoxHelper.Watermark="TextBox 01" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 02" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 03" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 04" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 05" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 06" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 07" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 08" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 09" />
<TextBox Margin="0 5 0 0" Controls:TextBoxHelper.Watermark="TextBox 10" />
</StackPanel>
</ScrollViewer>
</TabItem>
<TabItem Header="Empty" />
</TabControl>
<UniformGrid Grid.Row="2"
Margin="10"
Columns="2">
<Button Margin="10"
Content="Create"
Style="{DynamicResource MahApps.Styles.Button.Square}" />
<Button Margin="10"
Content="Cancel"
Style="{DynamicResource MahApps.Styles.Button.Square}" />
</UniformGrid>
</Grid>
</Controls:Flyout>
<Controls:Flyout HorizontalContentAlignment="Stretch"
AnimateOpacity="True"
CloseButtonIsCancel="True"
Header="New Goodness"
Position="Right">
<StackPanel Margin="10" Orientation="Vertical">
<Button Margin="2"
Content="create"
Style="{StaticResource MahApps.Styles.Button.Flat}" />
<Button Margin="2"
Content="cancel"
Style="{StaticResource MahApps.Styles.Button.Flat}" />
</StackPanel>
</Controls:Flyout>
<exampleWindows:ShowcaseFlyout DataContext="{Binding}" />
<Controls:Flyout Header="Accented"
Position="Right"
Theme="Accent">
<Grid Width="400" Margin="10">
<StackPanel>
<TextBlock Text="This flyout adapts its theme to the current accent" />
<GroupBox Height="250"
Margin="10"
Header="Flyout Group Box" />
<Button Margin="10" Content="Button" />
<ToggleButton Margin="10" Content="Toggle Button" />
</StackPanel>
</Grid>
</Controls:Flyout>
<Controls:Flyout Header="Inverse"
Position="Right"
Theme="Inverse">
<Grid Width="400" Margin="10">
<TextBlock Text="This flyout has the inverse theme of the current window theme" />
</Grid>
</Controls:Flyout>
<Controls:Flyout Header="Adapt"
Position="Right"
Theme="Adapt">
<Grid Width="400" Margin="10">
<TextBlock Text="This flyout adapts the theme of the current window" />
</Grid>
</Controls:Flyout>
<Controls:Flyout AnimateOnPositionChange="{Binding AnimateOnPositionChange}"
Header="Cool"
Position="Right">
<Grid Width="270" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0"
Grid.Column="0"
Margin="5"
VerticalAlignment="Center"
Content="Download language:" />
<ComboBox x:Name="flyoutSettingsComboboxDownloadlanguage"
Grid.Row="0"
Grid.Column="1"
Margin="0 5 5 5"
VerticalAlignment="Center" />
<Button x:Name="flyoutSettingsButtonSave"
Grid.Row="1"
Grid.Column="1"
Width="75"
Margin="5"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Content="Save"
Style="{StaticResource MahApps.Styles.Button.Flat}" />
<UniformGrid Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="10"
Columns="3">
<CheckBox IsChecked="{Binding AnimateOnPositionChange}">Animate</CheckBox>
<Button Margin="10"
Click="ShowSettingsLeft"
Content="Left"
Style="{DynamicResource MahApps.Styles.Button.Square}" />
<Button Margin="10"
Click="ShowSettingsRight"
Content="Right"
Style="{DynamicResource MahApps.Styles.Button.Square}" />
</UniformGrid>
</Grid>
</Controls:Flyout>
<Controls:Flyout Header="Left" Position="Left">
<StackPanel Width="150" Margin="5 5 5 5">
<TextBlock Text="a test for left" />
<CheckBox Content="a simple checkbox" />
<RadioButton Content="a simple RadioButton" />
<ComboBox>
<ComboBoxItem>Item 1</ComboBoxItem>
<ComboBoxItem>Item 2</ComboBoxItem>
<ComboBoxItem>Item 3</ComboBoxItem>
</ComboBox>
</StackPanel>
</Controls:Flyout>
<Controls:Flyout Margin="50 0 50 0"
CloseButtonVisibility="Collapsed"
Header="Top"
IsModal="True"
Position="Top"
Theme="Light"
TitleVisibility="Collapsed">
<Grid Height="150">
<TextBlock Margin="10"
FontSize="22"
Text="Flyout on the top..." />
<Grid VerticalAlignment="Bottom" Background="{DynamicResource MahApps.Brushes.Accent2}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Grid.Column="1"
Margin="5"
Content="_Save"
IsEnabled="False"
Style="{DynamicResource MahApps.Styles.Button.Flat}" />
<Button Grid.Column="2"
Margin="5"
Click="TopFlyoutCloseButtonOnClick"
Content="_Close"
IsCancel="True"
Style="{DynamicResource MahApps.Styles.Button.Flat}" />
</Grid>
</Grid>
</Controls:Flyout>
<Controls:Flyout Height="150"
Header="Top"
Position="Top">
<StackPanel Height="80"
Margin="5"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Orientation="Horizontal">
<Button Width="36"
Height="36"
Style="{DynamicResource MahApps.Styles.Button.Circle}">
<iconPacks:PackIconModern Kind="Alert" />
</Button>
</StackPanel>
</Controls:Flyout>
<Controls:Flyout Header="Bottom" Position="Bottom">
<StackPanel Height="80"
Margin="5 5 5 5"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button Width="36"
Height="36"
FontFamily="Segoe UI Symbol"
FontSize="16"
Style="{DynamicResource MahApps.Styles.Button.Circle}">
<iconPacks:PackIconModern Kind="Add" />
</Button>
</StackPanel>
</Controls:Flyout>
<Controls:Flyout Header="Modal"
IsModal="True"
Position="Right">
<StackPanel Height="80"
Margin="5 5 5 5"
Orientation="Horizontal">
<TextBlock>Modal Flyout</TextBlock>
</StackPanel>
</Controls:Flyout>
<Controls:Flyout Height="75"
CloseButtonVisibility="Collapsed"
IsPinned="False"
Position="Bottom"
TitleVisibility="Collapsed">
<TextBlock VerticalAlignment="Center" Text="This is an AppBar" />
</Controls:Flyout>
<Controls:Flyout x:Name="AutoCloseFlyout"
AutoCloseInterval="6000"
CloseButtonVisibility="Collapsed"
Header="AutoClose"
IsAutoCloseEnabled="True"
Position="Right">
<StackPanel Width="400"
Margin="10"
SnapsToDevicePixels="True">
<CheckBox Margin="4"
Content="AutoClose Enabled"
IsChecked="{Binding IsAutoCloseEnabled, ElementName=AutoCloseFlyout, Mode=TwoWay}" />
<Slider Margin="4"
IsSnapToTickEnabled="True"
Maximum="12000"
Minimum="2000"
TickFrequency="2000"
Value="{Binding AutoCloseInterval, ElementName=AutoCloseFlyout, Mode=TwoWay}" />
<TextBlock Margin="4">
<Run Text="This flyout will auto close after " />
<Run Text="{Binding AutoCloseInterval, ElementName=AutoCloseFlyout, Mode=OneWay}" />
<Run Text=" milliseconds" />
</TextBlock>
</StackPanel>
</Controls:Flyout>
</Controls:FlyoutsControl>
</Controls:MetroWindow.Flyouts>
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource MahApps.Styles.Button.Flat}" TargetType="{x:Type Button}" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="3"
Margin="10"
FontSize="30"
Text="Some Flyout Tests..." />
<StackPanel Grid.Row="1"
Grid.Column="0"
MinWidth="200"
Margin="5"
HorizontalAlignment="Center">
<Button Margin="2"
Command="{Binding OpenFirstFlyoutCommand}"
CommandParameter="{Binding ElementName=settingsFlyout}"
Content="Show 1" />
<Button Margin="2"
Click="ShowSecond"
Content="Show 2" />
<Button Margin="2"
Click="ShowThird"
Content="Show 3" />
<Button Margin="2"
Click="ShowAccent"
Content="Accent" />
<Button Margin="2"
Click="ShowInverse"
Content="Inverse" />
<Button Margin="2"
Click="ShowAdapt"
Content="Adapt" />
<Button Margin="2"
Click="ShowSettings"
Content="Settings" />
<Button Margin="2"
Click="ShowModal"
Content="Modal" />
<Button Margin="2"
Click="ShowAppBar"
Content="AppBar" />
<Button Margin="2"
Click="ShowDynamicFlyout"
Content="Dynamic" />
<Button Margin="2"
Click="ShowAutoCloseFlyout"
Content="AutoClose" />
</StackPanel>
<AdornerDecorator Grid.Row="1"
Grid.Column="1"
MinWidth="100"
Margin="5"
HorizontalAlignment="Center"
VerticalAlignment="Top">
<TextBox Controls:TextBoxHelper.Watermark="Number greater than 10" Text="{Binding IntegerGreater10Property, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}" />
</AdornerDecorator>
<StackPanel Grid.Row="1"
Grid.Column="2"
MinWidth="120"
Margin="5"
HorizontalAlignment="Center"
Grid.IsSharedSizeScope="True">
<TextBlock Margin="5"
FontSize="30"
Text="OverlayBehavior" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" SharedSizeGroup="labels" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
Text="LeftWindowCommands" />
<ComboBox Grid.Column="1"
Width="100"
Margin="2"
VerticalAlignment="Center"
ItemsSource="{Binding Source={StaticResource WindowCommandsOverlayBehaviorValues}}"
SelectedValue="{Binding ElementName=flyoutsDemo, Path=LeftWindowCommandsOverlayBehavior, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" SharedSizeGroup="labels" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
Text="RightWindowCommands" />
<ComboBox Grid.Column="1"
Width="100"
Margin="2"
VerticalAlignment="Center"
ItemsSource="{Binding Source={StaticResource WindowCommandsOverlayBehaviorValues}}"
SelectedValue="{Binding ElementName=flyoutsDemo, Path=RightWindowCommandsOverlayBehavior, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" SharedSizeGroup="labels" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
Text="WindowButtonCommands" />
<ComboBox Grid.Column="1"
Width="100"
Margin="2"
VerticalAlignment="Center"
ItemsSource="{Binding Source={StaticResource OverlayBehaviorValues}}"
SelectedValue="{Binding ElementName=flyoutsDemo, Path=WindowButtonCommandsOverlayBehavior, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" SharedSizeGroup="labels" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
Text="Icon" />
<ComboBox Grid.Column="1"
Width="100"
Margin="2"
VerticalAlignment="Center"
ItemsSource="{Binding Source={StaticResource OverlayBehaviorValues}}"
SelectedValue="{Binding ElementName=flyoutsDemo, Path=IconOverlayBehavior, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
<CheckBox Content="ShowTitleBar" IsChecked="{Binding ElementName=flyoutsDemo, Path=ShowTitleBar, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Button Margin="2 10 2 2"
Click="ShowLeft"
Content="Show Left" />
<Button Margin="2"
Click="ShowCustomTop"
Content="Show Custom Top" />
<Button Margin="2"
Click="ShowTop"
Content="Show Top" />
<Button Margin="2"
Click="ShowBottom"
Content="Show Bottom" />
<Button Margin="2"
Click="CloseMe"
Content="Close" />
</StackPanel>
</Grid>
</Controls:MetroWindow>