Skip to content

Commit 2b5e9e2

Browse files
committed
fix(popupbox): add support for Background, BorderBrush, BorderThickness and ButtonAssist.CornerRadius and hover-effect to PopupBox
1 parent cfd21b9 commit 2b5e9e2

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PopupBox.xaml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,40 @@
9595
<Setter Property="Template">
9696
<Setter.Value>
9797
<ControlTemplate TargetType="ToggleButton">
98-
<wpf:Ripple Padding="{TemplateBinding Padding}"
99-
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
100-
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
101-
Content="{TemplateBinding Content}"
102-
ContentTemplate="{TemplateBinding ContentTemplate}"
103-
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
104-
Focusable="False"
105-
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
98+
<Grid>
99+
<Border x:Name="border"
100+
Background="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=wpf:PopupBox}, Path=Background}"
101+
BorderBrush="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=wpf:PopupBox}, Path=BorderBrush}"
102+
BorderThickness="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=wpf:PopupBox}, Path=BorderThickness}"
103+
CornerRadius="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=wpf:PopupBox}, Path=(wpf:ButtonAssist.CornerRadius)}" />
104+
105+
<wpf:Ripple Padding="{TemplateBinding Padding}"
106+
ClipToBounds="True"
107+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
108+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
109+
Content="{TemplateBinding Content}"
110+
ContentTemplate="{TemplateBinding ContentTemplate}"
111+
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
112+
Focusable="False"
113+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
114+
<wpf:Ripple.Clip>
115+
<MultiBinding Converter="{x:Static converters:BorderClipConverter.Instance}">
116+
<Binding ElementName="border" Path="ActualWidth" />
117+
<Binding ElementName="border" Path="ActualHeight" />
118+
<Binding ElementName="border" Path="CornerRadius" />
119+
<Binding ElementName="border" Path="BorderThickness" />
120+
</MultiBinding>
121+
</wpf:Ripple.Clip>
122+
</wpf:Ripple>
123+
</Grid>
124+
<ControlTemplate.Triggers>
125+
<Trigger Property="IsMouseOver" Value="true">
126+
<Setter TargetName="border" Property="Background" Value="{Binding Foreground, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={x:Static converters:BrushOpacityConverter.Instance}, ConverterParameter=0.16}" />
127+
</Trigger>
128+
<Trigger Property="IsEnabled" Value="false">
129+
<Setter Property="Opacity" Value="0.38" />
130+
</Trigger>
131+
</ControlTemplate.Triggers>
106132
</ControlTemplate>
107133
</Setter.Value>
108134
</Setter>

0 commit comments

Comments
 (0)