|
15 | 15 | </ResourceDictionary.MergedDictionaries>
|
16 | 16 | </ResourceDictionary>
|
17 | 17 | </UserControl.Resources>
|
18 |
| - <Grid> |
| 18 | + |
| 19 | + <Grid VerticalAlignment="Center"> |
19 | 20 | <Grid.RowDefinitions>
|
20 | 21 | <RowDefinition Height="Auto" />
|
21 |
| - <RowDefinition Height="*" /> |
| 22 | + <RowDefinition Height="*" /> |
22 | 23 | </Grid.RowDefinitions>
|
23 |
| - <StackPanel> |
24 |
| - <TextBlock>WORK IN PROGRESS...DO NOT USE YET...API NOT FINALISED.</TextBlock> |
25 |
| - <!-- |
26 |
| - <TextBlock>Dialogs can be hosted at any level of you visual tree.</TextBlock> |
27 |
| - <TextBlock>When a dialog is open the underlying content will be disabled.</TextBlock> |
28 |
| - --> |
29 |
| - </StackPanel> |
30 |
| - |
31 |
| - <Grid Grid.Row="1"> |
32 |
| - <Grid.RowDefinitions> |
33 |
| - <RowDefinition Height="Auto" /> |
34 |
| - <RowDefinition Height="*" /> |
35 |
| - </Grid.RowDefinitions> |
36 |
| - <Grid.ColumnDefinitions> |
37 |
| - <ColumnDefinition Width="1*" /> |
38 |
| - <ColumnDefinition Width="1*" /> |
39 |
| - <ColumnDefinition Width="1*" /> |
40 |
| - <ColumnDefinition Width="1*" /> |
41 |
| - </Grid.ColumnDefinitions> |
| 24 | + <Grid.ColumnDefinitions> |
| 25 | + <ColumnDefinition Width="1*" /> |
| 26 | + <ColumnDefinition Width="1*" /> |
| 27 | + <ColumnDefinition Width="1*" /> |
| 28 | + </Grid.ColumnDefinitions> |
42 | 29 |
|
43 |
| - <!--#region SAMPLE 1--> |
44 |
| - <TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" |
45 |
| - Margin="16">SAMPLE 1: Localised dialog encapsulating specific content, launched from a routed command, response handled in code-behind.</TextBlock> |
46 |
| - <wpf:DialogHost DialogClosing="Sample1_DialogHost_OnDialogClosing" |
47 |
| - Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"> |
48 |
| - <wpf:DialogHost.DialogContent> |
49 |
| - <StackPanel Margin="16"> |
50 |
| - <TextBlock>Add a new fruit.</TextBlock> |
51 |
| - <TextBox Margin="0 8 0 0" HorizontalAlignment="Stretch" x:Name="FruitTextBox" /> |
52 |
| - <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" > |
53 |
| - <Button Style="{StaticResource MaterialDesignFlatButton}" |
54 |
| - IsDefault="True" |
55 |
| - Margin="0 8 8 0" |
56 |
| - Command="wpf:DialogHost.CloseDialogCommand"> |
57 |
| - <Button.CommandParameter> |
58 |
| - <system:Boolean>True</system:Boolean> |
59 |
| - </Button.CommandParameter> |
60 |
| - ACCEPT |
61 |
| - </Button> |
62 |
| - <Button Style="{StaticResource MaterialDesignFlatButton}" |
63 |
| - IsCancel="True" |
64 |
| - Margin="0 8 8 0" |
65 |
| - Command="wpf:DialogHost.CloseDialogCommand"> |
66 |
| - <Button.CommandParameter> |
67 |
| - <system:Boolean>False</system:Boolean> |
68 |
| - </Button.CommandParameter> |
69 |
| - CANCEL |
70 |
| - </Button> |
71 |
| - </StackPanel> |
72 |
| - </StackPanel> |
73 |
| - </wpf:DialogHost.DialogContent> |
74 |
| - <Border BorderThickness="1" BorderBrush="{DynamicResource PrimaryHueMidBrush}" |
75 |
| - MinWidth="256" MinHeight="256"> |
76 |
| - <Grid> |
77 |
| - <Grid.RowDefinitions> |
78 |
| - <RowDefinition Height="*" /> |
79 |
| - <RowDefinition Height="Auto" /> |
80 |
| - </Grid.RowDefinitions> |
81 |
| - <ListBox x:Name="FruitListBox"> |
82 |
| - <ListBoxItem>Apple</ListBoxItem> |
83 |
| - <ListBoxItem>Banana</ListBoxItem> |
84 |
| - <ListBoxItem>Pear</ListBoxItem> |
85 |
| - </ListBox> |
86 |
| - <wpf:ColorZone Mode="PrimaryMid" Grid.Row="1"> |
87 |
| - <TextBlock Margin="16">Fruit Bowl</TextBlock> |
88 |
| - </wpf:ColorZone> |
89 |
| - <Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}" |
90 |
| - Command="{x:Static wpf:DialogHost.OpenDialogCommand}" |
91 |
| - VerticalAlignment="Bottom" HorizontalAlignment="Right" |
92 |
| - Grid.Row="0" Margin="0 0 28 -20"> |
93 |
| - <Viewbox Width="22" Height="22"> |
94 |
| - <Canvas Width="24" Height="24"> |
95 |
| - <Path Data="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" /> |
96 |
| - </Canvas> |
97 |
| - </Viewbox> |
| 30 | + <!--#region SAMPLE 1--> |
| 31 | + <TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Top" |
| 32 | + Margin="16">SAMPLE 1: Localised dialog encapsulating specific content, launched from a routed command, response handled in code-behind.</TextBlock> |
| 33 | + <wpf:DialogHost DialogClosing="Sample1_DialogHost_OnDialogClosing" |
| 34 | + Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"> |
| 35 | + <wpf:DialogHost.DialogContent> |
| 36 | + <StackPanel Margin="16"> |
| 37 | + <TextBlock>Add a new fruit.</TextBlock> |
| 38 | + <TextBox Margin="0 8 0 0" HorizontalAlignment="Stretch" x:Name="FruitTextBox" /> |
| 39 | + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" > |
| 40 | + <Button Style="{StaticResource MaterialDesignFlatButton}" |
| 41 | + IsDefault="True" |
| 42 | + Margin="0 8 8 0" |
| 43 | + Command="wpf:DialogHost.CloseDialogCommand"> |
| 44 | + <Button.CommandParameter> |
| 45 | + <system:Boolean>True</system:Boolean> |
| 46 | + </Button.CommandParameter> |
| 47 | + ACCEPT |
| 48 | + </Button> |
| 49 | + <Button Style="{StaticResource MaterialDesignFlatButton}" |
| 50 | + IsCancel="True" |
| 51 | + Margin="0 8 8 0" |
| 52 | + Command="wpf:DialogHost.CloseDialogCommand"> |
| 53 | + <Button.CommandParameter> |
| 54 | + <system:Boolean>False</system:Boolean> |
| 55 | + </Button.CommandParameter> |
| 56 | + CANCEL |
98 | 57 | </Button>
|
99 |
| - </Grid> |
100 |
| - </Border> |
101 |
| - </wpf:DialogHost> |
102 |
| - <!--#endregion --> |
| 58 | + </StackPanel> |
| 59 | + </StackPanel> |
| 60 | + </wpf:DialogHost.DialogContent> |
| 61 | + <Border BorderThickness="1" BorderBrush="{DynamicResource PrimaryHueMidBrush}" |
| 62 | + MinWidth="256" MinHeight="256"> |
| 63 | + <Grid> |
| 64 | + <Grid.RowDefinitions> |
| 65 | + <RowDefinition Height="*" /> |
| 66 | + <RowDefinition Height="Auto" /> |
| 67 | + </Grid.RowDefinitions> |
| 68 | + <ListBox x:Name="FruitListBox"> |
| 69 | + <ListBoxItem>Apple</ListBoxItem> |
| 70 | + <ListBoxItem>Banana</ListBoxItem> |
| 71 | + <ListBoxItem>Pear</ListBoxItem> |
| 72 | + </ListBox> |
| 73 | + <wpf:ColorZone Mode="PrimaryMid" Grid.Row="1"> |
| 74 | + <TextBlock Margin="16">Fruit Bowl</TextBlock> |
| 75 | + </wpf:ColorZone> |
| 76 | + <Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}" |
| 77 | + Command="{x:Static wpf:DialogHost.OpenDialogCommand}" |
| 78 | + VerticalAlignment="Bottom" HorizontalAlignment="Right" |
| 79 | + Grid.Row="0" Margin="0 0 28 -20"> |
| 80 | + <Viewbox Width="22" Height="22"> |
| 81 | + <Canvas Width="24" Height="24"> |
| 82 | + <Path Data="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" /> |
| 83 | + </Canvas> |
| 84 | + </Viewbox> |
| 85 | + </Button> |
| 86 | + </Grid> |
| 87 | + </Border> |
| 88 | + </wpf:DialogHost> |
| 89 | + <!--#endregion --> |
103 | 90 |
|
104 |
| - <!--#region SAMPLE 2--> |
105 |
| - <TextBlock Grid.Column="1" Grid.Row="0" TextWrapping="Wrap">SAMPLE 2: Using OpenDialog, passing content via the Parameter. You can pass a view model, provided a corresponding DataTemplate can be found in the scope of the root DialogHost.</TextBlock> |
106 |
| - <StackPanel Grid.Column="1" Grid.Row="1"> |
107 |
| - <!--the request to open the dialog will bubble up to the top-most DialogHost, but we can used the attached property based event to handle the response --> |
108 |
| - <Button Command="{x:Static wpf:DialogHost.OpenDialogCommand}" |
109 |
| - wpf:DialogHost.DialogClosing="Sample2_DialogHost_OnDialogClosing" |
110 |
| - Width="128"> |
111 |
| - <Button.CommandParameter> |
112 |
| - <StackPanel Margin="16"> |
113 |
| - <ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="16" IsIndeterminate="True" Value="0" /> |
114 |
| - <Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" |
115 |
| - Command="{x:Static wpf:DialogHost.CloseDialogCommand}" |
116 |
| - CommandParameter="Sample2Cancel" |
117 |
| - HorizontalAlignment="Center">CANCEL</Button> |
118 |
| - </StackPanel> |
119 |
| - </Button.CommandParameter> |
120 |
| - PASS VIEW |
121 |
| - </Button> |
122 |
| - <Button Command="{x:Static wpf:DialogHost.OpenDialogCommand}" |
123 |
| - Width="128" Margin="0 32 0 0"> |
124 |
| - <Button.CommandParameter> |
125 |
| - <!-- the simplest view model of all, a DateTime. the view can be found in the resources of MainWindow.xaml --> |
126 |
| - <system:DateTime>1966-JUL-30</system:DateTime> |
127 |
| - </Button.CommandParameter> |
128 |
| - PASS MODEL |
129 |
| - </Button> |
130 |
| - </StackPanel> |
131 |
| - <!--#endregion--> |
132 |
| - </Grid> |
| 91 | + <!--#region SAMPLE 2--> |
| 92 | + <TextBlock Grid.Column="1" Grid.Row="0" TextWrapping="Wrap" VerticalAlignment="Top">SAMPLE 2: Top level dialog, using OpenDialog, passing content via the Parameter. You can pass a view model, provided a corresponding DataTemplate can be found in the scope of the root DialogHost.</TextBlock> |
| 93 | + <StackPanel Grid.Column="1" Grid.Row="1" VerticalAlignment="Center"> |
| 94 | + <!--the request to open the dialog will bubble up to the top-most DialogHost, but we can used the attached property based event to handle the response --> |
| 95 | + <Button Command="{x:Static wpf:DialogHost.OpenDialogCommand}" |
| 96 | + wpf:DialogHost.DialogClosing="Sample2_DialogHost_OnDialogClosing" |
| 97 | + Width="128"> |
| 98 | + <Button.CommandParameter> |
| 99 | + <StackPanel Margin="16"> |
| 100 | + <ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="16" IsIndeterminate="True" Value="0" /> |
| 101 | + <Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" |
| 102 | + Command="{x:Static wpf:DialogHost.CloseDialogCommand}" |
| 103 | + CommandParameter="Sample2Cancel" |
| 104 | + HorizontalAlignment="Center">CANCEL</Button> |
| 105 | + </StackPanel> |
| 106 | + </Button.CommandParameter> |
| 107 | + PASS VIEW |
| 108 | + </Button> |
| 109 | + <Button Command="{x:Static wpf:DialogHost.OpenDialogCommand}" |
| 110 | + Width="128" Margin="0 32 0 0"> |
| 111 | + <Button.CommandParameter> |
| 112 | + <!-- the simplest view model of all, a DateTime. the view can be found in the resources of MainWindow.xaml --> |
| 113 | + <system:DateTime>1966-JUL-30</system:DateTime> |
| 114 | + </Button.CommandParameter> |
| 115 | + PASS MODEL |
| 116 | + </Button> |
| 117 | + </StackPanel> |
| 118 | + <!--#endregion--> |
| 119 | + |
| 120 | + <!--#region SAMPLE 3--> |
| 121 | + <TextBlock Grid.Column="2" Grid.Row="0" TextWrapping="Wrap" VerticalAlignment="Top">SAMPLE 3: Open and listen to the dialog entirely from code in a view model.</TextBlock> |
| 122 | + <!-- Executes a command on DialogsViewModel.cs, which will launch the dialog from code --> |
| 123 | + <Button Grid.Column="2" Grid.Row="1" Command="{Binding RunDialogCommand}" |
| 124 | + Width="128"> |
| 125 | + RUN CODE |
| 126 | + </Button> |
| 127 | + <!--#endregion--> |
133 | 128 | </Grid>
|
| 129 | + |
134 | 130 | </UserControl>
|
0 commit comments