Skip to content

Commit b29ec07

Browse files
committed
just a bit of text
1 parent 7b3837b commit b29ec07

File tree

1 file changed

+108
-101
lines changed

1 file changed

+108
-101
lines changed

MainDemo.Wpf/Dialogs.xaml

Lines changed: 108 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -16,115 +16,122 @@
1616
</ResourceDictionary>
1717
</UserControl.Resources>
1818

19-
<Grid VerticalAlignment="Center">
19+
<Grid>
2020
<Grid.RowDefinitions>
2121
<RowDefinition Height="Auto" />
2222
<RowDefinition Height="*" />
2323
</Grid.RowDefinitions>
24-
<Grid.ColumnDefinitions>
25-
<ColumnDefinition Width="1*" />
26-
<ColumnDefinition Width="1*" />
27-
<ColumnDefinition Width="1*" />
28-
</Grid.ColumnDefinitions>
24+
<TextBlock TextWrapping="Wrap" Margin="32">Dialogs are supported via the DialogHost control which was designed to work with MVVM/binding, code-behind, routed commands, and a pure code-based API.</TextBlock>
25+
26+
<Grid VerticalAlignment="Center" Grid.Row="1">
27+
<Grid.RowDefinitions>
28+
<RowDefinition Height="Auto" />
29+
<RowDefinition Height="*" />
30+
</Grid.RowDefinitions>
31+
<Grid.ColumnDefinitions>
32+
<ColumnDefinition Width="1*" />
33+
<ColumnDefinition Width="1*" />
34+
<ColumnDefinition Width="1*" />
35+
</Grid.ColumnDefinitions>
2936

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
57-
</Button>
37+
<!--#region SAMPLE 1-->
38+
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Top"
39+
Margin="16">SAMPLE 1: Localised dialog encapsulating specific content, launched from a routed command, response handled in code-behind.</TextBlock>
40+
<wpf:DialogHost DialogClosing="Sample1_DialogHost_OnDialogClosing"
41+
Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
42+
<wpf:DialogHost.DialogContent>
43+
<StackPanel Margin="16">
44+
<TextBlock>Add a new fruit.</TextBlock>
45+
<TextBox Margin="0 8 0 0" HorizontalAlignment="Stretch" x:Name="FruitTextBox" />
46+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
47+
<Button Style="{StaticResource MaterialDesignFlatButton}"
48+
IsDefault="True"
49+
Margin="0 8 8 0"
50+
Command="wpf:DialogHost.CloseDialogCommand">
51+
<Button.CommandParameter>
52+
<system:Boolean>True</system:Boolean>
53+
</Button.CommandParameter>
54+
ACCEPT
55+
</Button>
56+
<Button Style="{StaticResource MaterialDesignFlatButton}"
57+
IsCancel="True"
58+
Margin="0 8 8 0"
59+
Command="wpf:DialogHost.CloseDialogCommand">
60+
<Button.CommandParameter>
61+
<system:Boolean>False</system:Boolean>
62+
</Button.CommandParameter>
63+
CANCEL
64+
</Button>
65+
</StackPanel>
5866
</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 -->
67+
</wpf:DialogHost.DialogContent>
68+
<Border BorderThickness="1" BorderBrush="{DynamicResource PrimaryHueMidBrush}"
69+
MinWidth="256" MinHeight="256">
70+
<Grid>
71+
<Grid.RowDefinitions>
72+
<RowDefinition Height="*" />
73+
<RowDefinition Height="Auto" />
74+
</Grid.RowDefinitions>
75+
<ListBox x:Name="FruitListBox">
76+
<ListBoxItem>Apple</ListBoxItem>
77+
<ListBoxItem>Banana</ListBoxItem>
78+
<ListBoxItem>Pear</ListBoxItem>
79+
</ListBox>
80+
<wpf:ColorZone Mode="PrimaryMid" Grid.Row="1">
81+
<TextBlock Margin="16">Fruit Bowl</TextBlock>
82+
</wpf:ColorZone>
83+
<Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}"
84+
Command="{x:Static wpf:DialogHost.OpenDialogCommand}"
85+
VerticalAlignment="Bottom" HorizontalAlignment="Right"
86+
Grid.Row="0" Margin="0 0 28 -20">
87+
<Viewbox Width="22" Height="22">
88+
<Canvas Width="24" Height="24">
89+
<Path Data="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
90+
</Canvas>
91+
</Viewbox>
92+
</Button>
93+
</Grid>
94+
</Border>
95+
</wpf:DialogHost>
96+
<!--#endregion -->
9097

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"
98+
<!--#region SAMPLE 2-->
99+
<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>
100+
<StackPanel Grid.Column="1" Grid.Row="1" VerticalAlignment="Center">
101+
<!--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 -->
102+
<Button Command="{x:Static wpf:DialogHost.OpenDialogCommand}"
103+
wpf:DialogHost.DialogClosing="Sample2_DialogHost_OnDialogClosing"
104+
Width="128">
105+
<Button.CommandParameter>
106+
<StackPanel Margin="16">
107+
<ProgressBar Style="{DynamicResource MaterialDesignCircularProgressBar}" HorizontalAlignment="Center" Margin="16" IsIndeterminate="True" Value="0" />
108+
<Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True"
109+
Command="{x:Static wpf:DialogHost.CloseDialogCommand}"
110+
CommandParameter="Sample2Cancel"
111+
HorizontalAlignment="Center">CANCEL</Button>
112+
</StackPanel>
113+
</Button.CommandParameter>
114+
PASS VIEW
115+
</Button>
116+
<Button Command="{x:Static wpf:DialogHost.OpenDialogCommand}"
117+
Width="128" Margin="0 32 0 0">
118+
<Button.CommandParameter>
119+
<!-- the simplest view model of all, a DateTime. the view can be found in the resources of MainWindow.xaml -->
120+
<system:DateTime>1966-JUL-30</system:DateTime>
121+
</Button.CommandParameter>
122+
PASS MODEL
123+
</Button>
124+
</StackPanel>
125+
<!--#endregion-->
126+
127+
<!--#region SAMPLE 3-->
128+
<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>
129+
<!-- Executes a command on DialogsViewModel.cs, which will launch the dialog from code -->
130+
<Button Grid.Column="2" Grid.Row="1" Command="{Binding RunDialogCommand}"
97131
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
132+
RUN CODE
108133
</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-->
134+
<!--#endregion-->
135+
</Grid>
128136
</Grid>
129-
130137
</UserControl>

0 commit comments

Comments
 (0)