|
1 | 1 | <UserControl x:Class="MaterialDesignDemo.Snackbars"
|
2 | 2 | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
3 | 3 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
4 |
| - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
5 | 5 | xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
6 | 6 | xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
7 | 7 | xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
|
8 |
| - mc:Ignorable="d" |
| 8 | + mc:Ignorable="d" |
9 | 9 | d:DesignHeight="300" d:DesignWidth="300">
|
10 | 10 |
|
11 | 11 | <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
|
|
22 | 22 | </Grid.RowDefinitions>
|
23 | 23 |
|
24 | 24 | <!-- example 1 -->
|
25 |
| - <Border Background="{DynamicResource MaterialDesignSelection}" |
| 25 | + <Border Background="{DynamicResource MaterialDesignSelection}" |
26 | 26 | Padding="8 0 8 0">
|
27 | 27 | <Grid>
|
28 | 28 | <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
29 | 29 | <TextBlock TextWrapping="WrapWithOverflow" Style="{StaticResource MaterialDesignSubtitle1TextBlock}">Example 1.</TextBlock>
|
30 |
| - <TextBlock TextWrapping="WrapWithOverflow" >Simple definition within XAML. Use the toggle to display the message.</TextBlock> |
| 30 | + <TextBlock TextWrapping="WrapWithOverflow">Simple definition within XAML. Use the toggle to display the message.</TextBlock> |
31 | 31 | <ToggleButton IsChecked="{Binding ElementName=SnackbarOne, Path=IsActive, Mode=TwoWay}"
|
32 |
| - Margin="0 8 0 0"/> |
| 32 | + Margin="0 8 0 0" /> |
33 | 33 | </StackPanel>
|
34 | 34 |
|
35 | 35 | <smtx:XamlDisplay Key="snackbar_1">
|
36 | 36 | <!-- simplest form -->
|
37 |
| - <materialDesign:Snackbar Message="hello 1" |
38 |
| - IsActive="False" |
39 |
| - x:Name="SnackbarOne" /> |
| 37 | + <materialDesign:Snackbar Message="hello 1" |
| 38 | + IsActive="False" |
| 39 | + x:Name="SnackbarOne" /> |
40 | 40 | </smtx:XamlDisplay>
|
41 | 41 | </Grid>
|
42 | 42 | </Border>
|
43 | 43 |
|
44 | 44 | <!-- example 2 -->
|
45 |
| - <Border Background="{DynamicResource MaterialDesignPaper}" |
| 45 | + <Border Background="{DynamicResource MaterialDesignPaper}" |
46 | 46 | Padding="8 0 8 0"
|
47 | 47 | Grid.Column="1" Grid.Row="0">
|
48 | 48 | <Grid>
|
49 | 49 | <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
50 | 50 | <TextBlock TextWrapping="WrapWithOverflow" Style="{StaticResource MaterialDesignSubtitle1TextBlock}">Example 2.</TextBlock>
|
51 |
| - <TextBlock TextWrapping="WrapWithOverflow" >View source to see message defined in long hand, allowing action button content to be set.</TextBlock> |
| 51 | + <TextBlock TextWrapping="WrapWithOverflow">View source to see message defined in long hand, allowing action button content to be set.</TextBlock> |
52 | 52 | <ToggleButton IsChecked="{Binding ElementName=SnackbarTwo, Path=IsActive, Mode=TwoWay}"
|
53 | 53 | Margin="0 8 0 0" />
|
54 | 54 | </StackPanel>
|
55 | 55 |
|
56 | 56 | <smtx:XamlDisplay Key="snackbar_2">
|
57 | 57 | <!-- long hand form for setting the message -->
|
58 |
| - <materialDesign:Snackbar IsActive="False" x:Name="SnackbarTwo" > |
| 58 | + <materialDesign:Snackbar IsActive="False" x:Name="SnackbarTwo"> |
59 | 59 | <materialDesign:SnackbarMessage Content="Hello 2" ActionContent="UNDO" />
|
60 | 60 | </materialDesign:Snackbar>
|
61 | 61 | </smtx:XamlDisplay>
|
|
66 | 66 | <!--
|
67 | 67 | * using a message queue to manage queuing of messages, and getting onto correct thread
|
68 | 68 | * notice the shorthand syntax {materialDesign:MessageQueue} for creating a new message
|
69 |
| - queue without expanded XAML. useful in code-behind scenarios if you dont want to bind |
| 69 | + queue without expanded XAML. useful in code-behind scenarios if you do not want to bind |
70 | 70 | a message queue in to the snackbar.
|
71 | 71 | -->
|
72 |
| - <Border Background="{DynamicResource MaterialDesignSelection}" |
| 72 | + <Border Background="{DynamicResource MaterialDesignSelection}" |
73 | 73 | Padding="8 0 8 0" Grid.Row="0" Grid.Column="2">
|
74 | 74 | <Grid>
|
75 | 75 | <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
76 | 76 | <TextBlock TextWrapping="WrapWithOverflow" Style="{StaticResource MaterialDesignSubtitle1TextBlock}">Example 3.</TextBlock>
|
77 | 77 | <TextBlock TextWrapping="WrapWithOverflow">In many real world scenario, notification display must deal with threading, queuing, and potentially heavy usage. A MessageQueue can be set to handle much of this for you, gicing the following benefits:</TextBlock>
|
78 |
| - <TextBlock TextWrapping="WrapWithOverflow" Margin="0 8 0 0" Text=" • Messages can be queued from any thread"/> |
79 |
| - <TextBlock TextWrapping="WrapWithOverflow" Text=" • Message will auto hide after a time out period"/> |
80 |
| - <TextBlock TextWrapping="WrapWithOverflow" Text=" • Notification will not time out if mouse is over it"/> |
81 |
| - <TextBlock TextWrapping="WrapWithOverflow" Text=" • Can be paired with a DialogHost so timeout will pause if a active dialog"/> |
82 |
| - <TextBlock TextWrapping="WrapWithOverflow" Text=" • Duplicate within a short period will be discarded"/> |
83 |
| - <TextBlock TextWrapping="WrapWithOverflow" Text=" • A single message queue can be shared acros multiple Windows"/> |
84 |
| - <TextBlock TextWrapping="WrapWithOverflow" Text=" • Works with code-behind and MVVM"/> |
| 78 | + <TextBlock TextWrapping="WrapWithOverflow" Margin="0 8 0 0" Text=" • Messages can be queued from any thread" /> |
| 79 | + <TextBlock TextWrapping="WrapWithOverflow" Text=" • Message will auto hide after a time out period" /> |
| 80 | + <TextBlock TextWrapping="WrapWithOverflow" Text=" • Notification will not time out if mouse is over it" /> |
| 81 | + <TextBlock TextWrapping="WrapWithOverflow" Text=" • Can be paired with a DialogHost so timeout will pause if a active dialog" /> |
| 82 | + <TextBlock TextWrapping="WrapWithOverflow" Text=" • Duplicate within a short period will be discarded" /> |
| 83 | + <TextBlock TextWrapping="WrapWithOverflow" Text=" • A single message queue can be shared acros multiple Windows" /> |
| 84 | + <TextBlock TextWrapping="WrapWithOverflow" Text=" • Works with code-behind and MVVM" /> |
85 | 85 | <Grid Margin="0 16 0 0">
|
86 | 86 | <Grid.ColumnDefinitions>
|
87 | 87 | <ColumnDefinition Width="*" />
|
88 | 88 | <ColumnDefinition Width="Auto" />
|
89 | 89 | </Grid.ColumnDefinitions>
|
90 |
| - <TextBox x:Name="MessageTextBox" VerticalAlignment="Top" |
91 |
| - Grid.Column="0">Hello World</TextBox> |
92 |
| - <Button Click="SnackBar3_OnClick" Margin="16 0 0 0" |
93 |
| - Grid.Column="1">Send</Button> |
| 90 | + <TextBox x:Name="MessageTextBox" VerticalAlignment="Top" Grid.Column="0">Hello World</TextBox> |
| 91 | + <Button Click="SnackBar3_OnClick" Margin="16 0 0 0" Grid.Column="1">Send</Button> |
94 | 92 | </Grid>
|
95 |
| - |
96 |
| - |
97 | 93 | </StackPanel>
|
98 | 94 | <smtx:XamlDisplay Key="snackbar_3" VerticalContentAlignment="Top">
|
99 | 95 | <materialDesign:Snackbar MessageQueue="{materialDesign:MessageQueue}"
|
|
104 | 100 |
|
105 | 101 | <!-- example 4 -->
|
106 | 102 | <!-- illustrates queueing uses some action command call backs -->
|
107 |
| - <Border Background="{DynamicResource MaterialDesignPaper}" |
| 103 | + <Border Background="{DynamicResource MaterialDesignPaper}" |
108 | 104 | Padding="8 0 8 0" Grid.Column="3" Grid.Row="0">
|
109 | 105 | <Grid>
|
110 | 106 | <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
|
117 | 113 | <ColumnDefinition Width="Auto" />
|
118 | 114 | </Grid.ColumnDefinitions>
|
119 | 115 | <TextBox AcceptsReturn="True" x:Name="ExampleFourTextBox" TextWrapping="Wrap"
|
120 |
| - Text="Message One
Message Two
Message Three
Duplicate
Duplicate
Duplicate
Start Fresh
Goodbye" /> |
| 116 | + Text="Message One
Message Two
Message Three
Duplicate
Duplicate
Duplicate
Start Fresh
Goodbye" /> |
121 | 117 | <Button Click="SnackBar4_OnClick" HorizontalAlignment="Center" Grid.Column="1">Send</Button>
|
122 | 118 | </Grid>
|
123 | 119 | </StackPanel>
|
124 | 120 | <smtx:XamlDisplay Key="snackbar_4">
|
125 | 121 | <materialDesign:Snackbar MessageQueue="{materialDesign:MessageQueue}"
|
126 |
| - x:Name="SnackbarFour" /> |
| 122 | + x:Name="SnackbarFour" /> |
127 | 123 | </smtx:XamlDisplay>
|
128 | 124 | </Grid>
|
129 | 125 | </Border>
|
130 | 126 |
|
131 | 127 | <!-- example 5 -->
|
132 | 128 | <!-- full width snack bar -->
|
133 |
| - <Border Background="{DynamicResource MaterialDesignChipBackground}" |
| 129 | + <Border Background="{DynamicResource MaterialDesignChipBackground}" |
134 | 130 | Grid.ColumnSpan="2" Grid.Row="1" Grid.Column="0">
|
135 | 131 | <StackPanel VerticalAlignment="Bottom">
|
136 | 132 | <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"
|
|
142 | 138 | </StackPanel>
|
143 | 139 | <smtx:XamlDisplay Key="snackbar_5" HorizontalAlignment="Stretch">
|
144 | 140 | <materialDesign:Snackbar HorizontalAlignment="Stretch"
|
145 |
| - x:Name="SnackbarFive"> |
| 141 | + x:Name="SnackbarFive"> |
146 | 142 | <materialDesign:SnackbarMessage Content="This Snackbar is stretched horizontally. Consider allowing your content to push up."
|
147 |
| - ActionContent="OK" /> |
| 143 | + ActionContent="OK" /> |
148 | 144 | </materialDesign:Snackbar>
|
149 | 145 | </smtx:XamlDisplay>
|
150 | 146 | </StackPanel>
|
|
159 | 155 | <!-- here is where you can get additional snackbar button styles from -->
|
160 | 156 | <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Snackbar.xaml" />
|
161 | 157 | </ResourceDictionary.MergedDictionaries>
|
| 158 | + <Style TargetType="materialDesign:Snackbar" BasedOn="{StaticResource {x:Type materialDesign:Snackbar}}"> |
| 159 | + <Setter Property="Width" Value="288" /> |
| 160 | + </Style> |
162 | 161 | </ResourceDictionary>
|
163 | 162 | </Border.Resources>
|
164 | 163 | <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
|
171 | 170 | </smtx:XamlDisplay>
|
172 | 171 | <smtx:XamlDisplay Key="snackbar_7" Margin="0 8 0 0">
|
173 | 172 | <materialDesign:Snackbar IsActive="True"
|
174 |
| - ActionButtonStyle="{StaticResource MaterialDesignSnackbarActionLightButton}"> |
175 |
| - <materialDesign:SnackbarMessage Content="Primary Light" ActionContent="LIGHT" /> |
| 173 | + ActionButtonStyle="{StaticResource MaterialDesignSnackbarActionLightButton}"> |
| 174 | + <materialDesign:SnackbarMessage Content="Primary Light - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." ActionContent="LIGHT - very long text" /> |
176 | 175 | </materialDesign:Snackbar>
|
177 | 176 | </smtx:XamlDisplay>
|
178 | 177 | <smtx:XamlDisplay Key="snackbar_8" Margin="0 8 0 0">
|
179 |
| - <materialDesign:Snackbar IsActive="True" ActionButtonStyle="{StaticResource MaterialDesignSnackbarActionMidButton}"> |
| 178 | + <materialDesign:Snackbar IsActive="True" |
| 179 | + ActionButtonStyle="{StaticResource MaterialDesignSnackbarActionMidButton}" |
| 180 | + ActionButtonPlacement="Inline"> |
180 | 181 | <materialDesign:SnackbarMessage Content="Primary Mid" ActionContent="MID" />
|
181 | 182 | </materialDesign:Snackbar>
|
182 | 183 | </smtx:XamlDisplay>
|
183 | 184 | <smtx:XamlDisplay Key="snackbar_9" Margin="0 8 0 0">
|
184 | 185 | <materialDesign:Snackbar IsActive="True"
|
185 |
| - ActionButtonStyle="{StaticResource MaterialDesignSnackbarActionDarkButton}"> |
186 |
| - <materialDesign:SnackbarMessage Content="Primary Dark" ActionContent="DARK" /> |
| 186 | + ActionButtonStyle="{StaticResource MaterialDesignSnackbarActionDarkButton}" |
| 187 | + ActionButtonPlacement="SeparateLine"> |
| 188 | + <materialDesign:SnackbarMessage |
| 189 | + Content="Primary Dark" |
| 190 | + ActionContent="DARK" /> |
187 | 191 | </materialDesign:Snackbar>
|
188 | 192 | </smtx:XamlDisplay>
|
189 | 193 | </StackPanel>
|
190 | 194 | </Border>
|
191 | 195 |
|
192 | 196 | <!-- example 7 -->
|
193 | 197 | <!-- message duration override -->
|
194 |
| - <Border Background="{DynamicResource MaterialDesignPaper}" |
| 198 | + <Border Background="{DynamicResource MaterialDesignPaper}" |
195 | 199 | Padding="8 0 8 0" Grid.Column="3" Grid.Row="1">
|
196 | 200 | <Grid>
|
197 | 201 | <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
|
219 | 223 | </Grid>
|
220 | 224 | </ScrollViewer>
|
221 | 225 | </UserControl>
|
222 |
| - |
|
0 commit comments