Skip to content

Commit 51b75f4

Browse files
committed
not much to see here yet
1 parent 62e1e21 commit 51b75f4

File tree

2 files changed

+148
-12
lines changed

2 files changed

+148
-12
lines changed

MainDemo.Wpf/App.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Application x:Class="MaterialDesignColors.WpfExample.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
StartupUri="MainWindow.xaml">
4+
StartupUri="ProvingGround.xaml">
55
<Application.Resources>
66
<ResourceDictionary>
77
<ResourceDictionary.MergedDictionaries>

MainDemo.Wpf/ProvingGround.xaml

Lines changed: 147 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,157 @@
2020
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
2121
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
2222
</ResourceDictionary.MergedDictionaries>
23+
24+
<Style x:Key="MaterialDesignToggleListBoxItem" TargetType="{x:Type ListBoxItem}">
25+
<Setter Property="Background" Value="Transparent"/>
26+
<Setter Property="BorderThickness" Value="0"/>
27+
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
28+
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
29+
<Setter Property="Padding" Value="8" />
30+
<Setter Property="SnapsToDevicePixels" Value="True"/>
31+
<Setter Property="Template">
32+
<Setter.Value>
33+
<ControlTemplate TargetType="{x:Type ListBoxItem}">
34+
<Border Background="{TemplateBinding Background}"
35+
BorderBrush="{TemplateBinding BorderBrush}"
36+
BorderThickness="{TemplateBinding BorderThickness}"
37+
Margin="{TemplateBinding Margin}"
38+
ClipToBounds="{TemplateBinding ClipToBounds}">
39+
<VisualStateManager.VisualStateGroups>
40+
<VisualStateGroup Name="CommonStates">
41+
<VisualStateGroup.Transitions>
42+
<VisualTransition GeneratedDuration="0:0:0.3" To="Normal">
43+
<VisualTransition.GeneratedEasingFunction>
44+
<CircleEase EasingMode="EaseOut"/>
45+
</VisualTransition.GeneratedEasingFunction>
46+
</VisualTransition>
47+
</VisualStateGroup.Transitions>
48+
<VisualState Name="Normal"/>
49+
<VisualState Name="MouseOver">
50+
<Storyboard>
51+
<DoubleAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="Opacity"
52+
To="0.1" Duration="0"/>
53+
</Storyboard>
54+
</VisualState>
55+
<VisualState Name="Disabled"/>
56+
</VisualStateGroup>
57+
<VisualStateGroup Name="SelectionStates">
58+
<VisualStateGroup.Transitions>
59+
<VisualTransition GeneratedDuration="0:0:0.6"/>
60+
</VisualStateGroup.Transitions>
61+
<VisualState Name="Selected">
62+
<Storyboard>
63+
<DoubleAnimation Storyboard.TargetName="SelectedBorder"
64+
Storyboard.TargetProperty="Opacity"
65+
To="0.18" Duration="0"/>
66+
</Storyboard>
67+
</VisualState>
68+
<VisualState Name="Unselected"/>
69+
<VisualState Name="SelectedUnfocused">
70+
<Storyboard>
71+
<DoubleAnimation Storyboard.TargetName="SelectedBorder"
72+
Storyboard.TargetProperty="Opacity"
73+
To="0.03" Duration="0"/>
74+
</Storyboard>
75+
</VisualState>
76+
</VisualStateGroup>
77+
</VisualStateManager.VisualStateGroups>
78+
<Grid>
79+
<Border x:Name="MouseOverBorder"
80+
Opacity="0"
81+
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">
87+
<Border.RenderTransform>
88+
<ScaleTransform ScaleX="1"/>
89+
</Border.RenderTransform>
90+
</Border>
91+
<materialDesign:Ripple Feedback="{TemplateBinding Foreground, Converter={StaticResource BrushRoundConverter}}"
92+
Focusable="False"
93+
Content="{TemplateBinding Content}"
94+
ContentTemplate="{TemplateBinding ContentTemplate}"
95+
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
96+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
97+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
98+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
99+
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+
</materialDesign:Ripple>
108+
</Grid>
109+
</Border>
110+
</ControlTemplate>
111+
</Setter.Value>
112+
</Setter>
113+
</Style>
114+
115+
<Style x:Key="MaterialDesignToggleListBox" TargetType="{x:Type ListBox}">
116+
<Setter Property="Background" Value="Transparent"/>
117+
<Setter Property="BorderBrush" Value="Transparent"/>
118+
<Setter Property="BorderThickness" Value="0"/>
119+
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}"/>
120+
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
121+
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
122+
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
123+
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
124+
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
125+
<Setter Property="VerticalContentAlignment" Value="Center"/>
126+
<Setter Property="ItemContainerStyle" Value="{StaticResource MaterialDesignToggleListBoxItem}"/>
127+
<Setter Property="ItemsPanel">
128+
<Setter.Value>
129+
<ItemsPanelTemplate>
130+
<StackPanel Orientation="Horizontal" />
131+
</ItemsPanelTemplate>
132+
</Setter.Value>
133+
</Setter>
134+
<Setter Property="Template">
135+
<Setter.Value>
136+
<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>
141+
</Border>
142+
<ControlTemplate.Triggers>
143+
<MultiTrigger>
144+
<MultiTrigger.Conditions>
145+
<Condition Property="IsGrouping" Value="true"/>
146+
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
147+
</MultiTrigger.Conditions>
148+
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
149+
</MultiTrigger>
150+
</ControlTemplate.Triggers>
151+
</ControlTemplate>
152+
</Setter.Value>
153+
</Setter>
154+
</Style>
155+
23156
</ResourceDictionary>
24157
</UserControl.Resources>
25158

26159
<StackPanel>
27-
<materialDesign:ColorZone Mode="PrimaryDark" Padding="8">
28-
<StackPanel>
29-
<materialDesign:TimePicker SelectedTime="{Binding SelectedTime}" HorizontalAlignment="Left" />
30-
<DatePicker HorizontalAlignment="Left" materialDesign:HintAssist.Hint="Some date"/>
31-
<Calendar />
32-
</StackPanel>
33-
</materialDesign:ColorZone>
34-
<StackPanel>
35-
<materialDesign:TimePicker SelectedTime="{Binding SelectedTime}" HorizontalAlignment="Left" />
36-
<DatePicker HorizontalAlignment="Left" materialDesign:HintAssist.Hint="Some date"/>
37-
</StackPanel>
160+
<ListBox Style="{StaticResource MaterialDesignToggleListBox}">
161+
<ListBoxItem>
162+
<materialDesign:PackIcon Kind="FormatAlignLeft"/>
163+
</ListBoxItem>
164+
<ListBoxItem>
165+
<materialDesign:PackIcon Kind="FormatAlignCenter"/>
166+
</ListBoxItem>
167+
<ListBoxItem>
168+
<materialDesign:PackIcon Kind="FormatAlignRight"/>
169+
</ListBoxItem>
170+
<ListBoxItem>
171+
<materialDesign:PackIcon Kind="FormatAlignJustify"/>
172+
</ListBoxItem>
173+
</ListBox>
38174

39175
</StackPanel>
40176

0 commit comments

Comments
 (0)