|
4 | 4 | xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
5 | 5 | x:Class="MaterialDesignColors.WpfExample.ProvingGround"
|
6 | 6 | xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
| 7 | + xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf" |
7 | 8 | xmlns:wpfExample="clr-namespace:MaterialDesignColors.WpfExample"
|
8 | 9 | TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
9 | 10 | Background="{DynamicResource MaterialDesignPaper}"
|
|
21 | 22 | <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
|
22 | 23 | </ResourceDictionary.MergedDictionaries>
|
23 | 24 |
|
| 25 | + <converters:EqualityToVisibilityConverter x:Key="EqualityToVisibilityConverter" /> |
| 26 | + |
24 | 27 | <Style x:Key="MaterialDesignToggleListBoxItem" TargetType="{x:Type ListBoxItem}">
|
25 | 28 | <Setter Property="Background" Value="Transparent"/>
|
26 | 29 | <Setter Property="BorderThickness" Value="0"/>
|
| 30 | + <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignDivider}"/> |
27 | 31 | <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
|
28 | 32 | <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
|
29 |
| - <Setter Property="Padding" Value="8" /> |
| 33 | + <Setter Property="Padding" Value="14 6 14 6" /> |
30 | 34 | <Setter Property="SnapsToDevicePixels" Value="True"/>
|
31 | 35 | <Setter Property="Template">
|
32 | 36 | <Setter.Value>
|
|
60 | 64 | </VisualStateGroup.Transitions>
|
61 | 65 | <VisualState Name="Selected">
|
62 | 66 | <Storyboard>
|
63 |
| - <DoubleAnimation Storyboard.TargetName="SelectedBorder" |
| 67 | + <DoubleAnimation Storyboard.TargetName="SelectedBackgroundBorder" |
64 | 68 | Storyboard.TargetProperty="Opacity"
|
65 | 69 | To="0.18" Duration="0"/>
|
| 70 | + <DoubleAnimation Storyboard.TargetName="SelectedBorder" |
| 71 | + Storyboard.TargetProperty="Opacity" |
| 72 | + To="1" Duration="0"/> |
66 | 73 | </Storyboard>
|
67 | 74 | </VisualState>
|
68 | 75 | <VisualState Name="Unselected"/>
|
|
79 | 86 | <Border x:Name="MouseOverBorder"
|
80 | 87 | Opacity="0"
|
81 | 88 | Background="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}"/>
|
82 |
| - |
83 |
| - <Border x:Name="SelectedBorder" |
84 |
| - Opacity="0" |
85 |
| - Background="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}" |
86 |
| - RenderTransformOrigin="0.5,0.5"> |
| 89 | + <Border x:Name="SelectedBackgroundBorder" |
| 90 | + Opacity="0" |
| 91 | + Background="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}" |
| 92 | + RenderTransformOrigin="0.5,0.5"> |
87 | 93 | <Border.RenderTransform>
|
88 | 94 | <ScaleTransform ScaleX="1"/>
|
89 | 95 | </Border.RenderTransform>
|
90 | 96 | </Border>
|
| 97 | + |
91 | 98 | <materialDesign:Ripple Feedback="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}"
|
92 | 99 | Focusable="False"
|
93 | 100 | Content="{TemplateBinding Content}"
|
|
97 | 104 | HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
98 | 105 | VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
99 | 106 | Padding="{TemplateBinding Padding}">
|
100 |
| - <materialDesign:Ripple.Resources> |
101 |
| - <Style TargetType="{x:Type materialDesign:PackIcon}" > |
102 |
| - <Setter Property="Width" Value="220" /> |
103 |
| - <Setter Property="Height" Value="220" /> |
104 |
| - <Setter Property="Foreground" Value="Red" /> |
105 |
| - </Style> |
106 |
| - </materialDesign:Ripple.Resources> |
| 107 | + |
107 | 108 | </materialDesign:Ripple>
|
| 109 | + <Border x:Name="SelectedBorder" |
| 110 | + Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListBox}, Path=SelectionMode, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static SelectionMode.Extended}, Mode=OneWay}" |
| 111 | + Opacity="0" |
| 112 | + BorderThickness="1 0 1 0" |
| 113 | + BorderBrush="{DynamicResource MaterialDesignDivider}" /> |
108 | 114 | </Grid>
|
109 | 115 | </Border>
|
110 | 116 | </ControlTemplate>
|
|
134 | 140 | <Setter Property="Template">
|
135 | 141 | <Setter.Value>
|
136 | 142 | <ControlTemplate TargetType="{x:Type ListBox}">
|
137 |
| - <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true"> |
138 |
| - <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}"> |
139 |
| - <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> |
140 |
| - </ScrollViewer> |
| 143 | + <ControlTemplate.Resources> |
| 144 | + <Style TargetType="{x:Type materialDesign:PackIcon}" > |
| 145 | + <Setter Property="Width" Value="22" /> |
| 146 | + <Setter Property="Height" Value="22" /> |
| 147 | + </Style> |
| 148 | + </ControlTemplate.Resources> |
| 149 | + <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true" |
| 150 | + Padding="{TemplateBinding Padding}"> |
| 151 | + <materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" HorizontalAlignment="Left"> |
| 152 | + <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> |
| 153 | + </materialDesign:Card> |
141 | 154 | </Border>
|
142 | 155 | <ControlTemplate.Triggers>
|
143 | 156 | <MultiTrigger>
|
|
156 | 169 | </ResourceDictionary>
|
157 | 170 | </UserControl.Resources>
|
158 | 171 |
|
159 |
| - <StackPanel> |
| 172 | + <StackPanel Margin="8"> |
160 | 173 | <ListBox Style="{StaticResource MaterialDesignToggleListBox}">
|
161 | 174 | <ListBoxItem>
|
162 |
| - <materialDesign:PackIcon Kind="FormatAlignLeft"/> |
| 175 | + <materialDesign:PackIcon Kind="FormatAlignLeft"/> |
163 | 176 | </ListBoxItem>
|
164 | 177 | <ListBoxItem>
|
165 | 178 | <materialDesign:PackIcon Kind="FormatAlignCenter"/>
|
|
171 | 184 | <materialDesign:PackIcon Kind="FormatAlignJustify"/>
|
172 | 185 | </ListBoxItem>
|
173 | 186 | </ListBox>
|
174 |
| - |
| 187 | + |
| 188 | + <ListBox Style="{StaticResource MaterialDesignToggleListBox}" |
| 189 | + SelectionMode="Extended" |
| 190 | + Margin="0 8 0 0"> |
| 191 | + <ListBoxItem> |
| 192 | + <materialDesign:PackIcon Kind="FormatBold"/> |
| 193 | + </ListBoxItem> |
| 194 | + <ListBoxItem> |
| 195 | + <materialDesign:PackIcon Kind="FormatItalic"/> |
| 196 | + </ListBoxItem> |
| 197 | + <ListBoxItem> |
| 198 | + <materialDesign:PackIcon Kind="FormatUnderline"/> |
| 199 | + </ListBoxItem> |
| 200 | + </ListBox> |
| 201 | + |
175 | 202 | </StackPanel>
|
176 | 203 |
|
177 | 204 | </UserControl>
|
0 commit comments