Skip to content

Commit c52119e

Browse files
committed
multi action : support explicit toggle on content.
1 parent cb50b48 commit c52119e

File tree

5 files changed

+170
-92
lines changed

5 files changed

+170
-92
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 96 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -34,100 +34,110 @@
3434
<RowDefinition Height="Auto" />
3535
</Grid.RowDefinitions>
3636
<TextBlock>Buttons</TextBlock>
37-
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0 24 0 0">
38-
<Button Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
39-
Margin="0 0 8 0" HorizontalAlignment="Left"
40-
ToolTip="MaterialDesignFloatingActionMiniLightButton">
41-
<Viewbox Width="24" Height="24">
42-
<Canvas Width="24" Height="24">
43-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
44-
</Canvas>
45-
</Viewbox>
46-
</Button>
47-
<Button Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
48-
Margin="0 0 8 0" HorizontalAlignment="Left"
49-
ToolTip="MaterialDesignFloatingActionMiniButton">
50-
<Viewbox Width="24" Height="24">
51-
<Canvas Width="24" Height="24">
52-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
53-
</Canvas>
54-
</Viewbox>
55-
</Button>
56-
<Button Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}"
57-
Margin="0 0 8 0" HorizontalAlignment="Left"
58-
ToolTip="MaterialDesignFloatingActionMiniDarkButton">
59-
<Viewbox Width="24" Height="24">
60-
<Canvas Width="24" Height="24">
61-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
62-
</Canvas>
63-
</Viewbox>
64-
</Button>
65-
<Button Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}"
66-
Margin="0 0 8 0" HorizontalAlignment="Left"
67-
ToolTip="MaterialDesignFloatingActionMiniAccentButton">
68-
<Viewbox Width="24" Height="24">
69-
<Canvas Width="24" Height="24">
70-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
71-
</Canvas>
72-
</Viewbox>
73-
</Button>
74-
<Button Style="{StaticResource MaterialDesignFloatingActionLightButton}"
75-
Margin="0 0 8 0" HorizontalAlignment="Left"
76-
ToolTip="MaterialDesignFloatingActionLightButton">
77-
<Viewbox Width="24" Height="24">
78-
<Canvas Width="24" Height="24">
79-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
80-
</Canvas>
81-
</Viewbox>
82-
</Button>
83-
<Button Style="{StaticResource MaterialDesignFloatingActionButton}"
84-
Margin="0 0 8 0" HorizontalAlignment="Left"
85-
ToolTip="MaterialDesignFloatingActionButton">
86-
<Viewbox Width="24" Height="24">
87-
<Canvas Width="24" Height="24">
88-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
89-
</Canvas>
90-
</Viewbox>
91-
</Button>
92-
<Button Style="{StaticResource MaterialDesignFloatingActionDarkButton}"
93-
Margin="0 0 8 0" HorizontalAlignment="Left"
94-
ToolTip="MaterialDesignFloatingActionDarkButton">
95-
<Viewbox Width="24" Height="24">
96-
<Canvas Width="24" Height="24">
97-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
98-
</Canvas>
99-
</Viewbox>
100-
</Button>
101-
<Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}"
102-
Margin="0 0 8 0" HorizontalAlignment="Left"
103-
ToolTip="MaterialDesignFloatingActionAccentButton">
104-
<Viewbox Width="24" Height="24">
105-
<Canvas Width="24" Height="24">
106-
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
107-
</Canvas>
108-
</Viewbox>
109-
</Button>
110-
<materialDesign:PopupBox Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}"
111-
PlacementMode="BottomAndAlignCentres"
112-
ToolTipService.Placement="Right"
113-
ToolTip="PopupBox, Style MaterialDesignMultiFloatingActionPopupBox">
114-
<StackPanel>
115-
<Button ToolTip="One">1</Button>
116-
<Button ToolTip="Two">2</Button>
117-
<Button ToolTip="Three">3</Button>
118-
</StackPanel>
119-
</materialDesign:PopupBox>
37+
<Grid Grid.Row="1" >
38+
<StackPanel Orientation="Horizontal" Margin="0 24 0 0">
39+
<Button Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
40+
Margin="0 0 8 0" HorizontalAlignment="Left"
41+
ToolTip="MaterialDesignFloatingActionMiniLightButton">
42+
<Viewbox Width="24" Height="24">
43+
<Canvas Width="24" Height="24">
44+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
45+
</Canvas>
46+
</Viewbox>
47+
</Button>
48+
<Button Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
49+
Margin="0 0 8 0" HorizontalAlignment="Left"
50+
ToolTip="MaterialDesignFloatingActionMiniButton">
51+
<Viewbox Width="24" Height="24">
52+
<Canvas Width="24" Height="24">
53+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
54+
</Canvas>
55+
</Viewbox>
56+
</Button>
57+
<Button Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}"
58+
Margin="0 0 8 0" HorizontalAlignment="Left"
59+
ToolTip="MaterialDesignFloatingActionMiniDarkButton">
60+
<Viewbox Width="24" Height="24">
61+
<Canvas Width="24" Height="24">
62+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
63+
</Canvas>
64+
</Viewbox>
65+
</Button>
66+
<Button Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}"
67+
Margin="0 0 8 0" HorizontalAlignment="Left"
68+
ToolTip="MaterialDesignFloatingActionMiniAccentButton">
69+
<Viewbox Width="24" Height="24">
70+
<Canvas Width="24" Height="24">
71+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
72+
</Canvas>
73+
</Viewbox>
74+
</Button>
75+
<Button Style="{StaticResource MaterialDesignFloatingActionLightButton}"
76+
Margin="0 0 8 0" HorizontalAlignment="Left"
77+
ToolTip="MaterialDesignFloatingActionLightButton">
78+
<Viewbox Width="24" Height="24">
79+
<Canvas Width="24" Height="24">
80+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
81+
</Canvas>
82+
</Viewbox>
83+
</Button>
84+
<Button Style="{StaticResource MaterialDesignFloatingActionButton}"
85+
Margin="0 0 8 0" HorizontalAlignment="Left"
86+
ToolTip="MaterialDesignFloatingActionButton">
87+
<Viewbox Width="24" Height="24">
88+
<Canvas Width="24" Height="24">
89+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
90+
</Canvas>
91+
</Viewbox>
92+
</Button>
93+
<Button Style="{StaticResource MaterialDesignFloatingActionDarkButton}"
94+
Margin="0 0 8 0" HorizontalAlignment="Left"
95+
ToolTip="MaterialDesignFloatingActionDarkButton">
96+
<Viewbox Width="24" Height="24">
97+
<Canvas Width="24" Height="24">
98+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
99+
</Canvas>
100+
</Viewbox>
101+
</Button>
102+
<Button Style="{StaticResource MaterialDesignFloatingActionAccentButton}"
103+
Margin="0 0 8 0" HorizontalAlignment="Left"
104+
ToolTip="MaterialDesignFloatingActionAccentButton">
105+
<Viewbox Width="24" Height="24">
106+
<Canvas Width="24" Height="24">
107+
<Path Data="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}" />
108+
</Canvas>
109+
</Viewbox>
110+
</Button>
111+
<materialDesign:PopupBox Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}"
112+
PlacementMode="BottomAndAlignCentres"
113+
ToolTipService.Placement="Right"
114+
ToolTip="PopupBox, Style MaterialDesignMultiFloatingActionPopupBox">
115+
<StackPanel>
116+
<Button ToolTip="One">1</Button>
117+
<Button ToolTip="Two">2</Button>
118+
<Button ToolTip="Three">3</Button>
119+
</StackPanel>
120+
</materialDesign:PopupBox>
121+
</StackPanel>
120122
<materialDesign:PopupBox Style="{StaticResource MaterialDesignMultiFloatingActionAccentPopupBox}"
121123
PlacementMode="BottomAndAlignCentres"
122-
Margin="48 0 0 0"
124+
HorizontalAlignment="Right"
125+
Margin="0 0 48 0"
123126
ToolTip="PopupBox, Style MaterialDesignMultiFloatingActionAccentPopupBox">
127+
<materialDesign:PopupBox.ToggleCheckedContent>
128+
<Viewbox Width="24" Height="24">
129+
<Canvas Width="24" Height="24">
130+
<Path Data="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" Fill="Black" />
131+
</Canvas>
132+
</Viewbox>
133+
</materialDesign:PopupBox.ToggleCheckedContent>
124134
<StackPanel>
125135
<Button ToolTip="One">1</Button>
126136
<Button ToolTip="Two">2</Button>
127137
<Button ToolTip="Three">3</Button>
128138
</StackPanel>
129-
</materialDesign:PopupBox>
130-
</StackPanel>
139+
</materialDesign:PopupBox>
140+
</Grid>
131141
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0 16 0 0">
132142
<Button Style="{StaticResource MaterialDesignRaisedLightButton}" Margin="0 0 8 0" Width="100"
133143
ToolTip="Resource name: MaterialDesignRaisedLightButton">

MaterialDesignThemes.Wpf/Converters/NotNullToVisibilityConverter.cs renamed to MaterialDesignThemes.Wpf/Converters/NullToVisibilityConverter.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55

66
namespace MaterialDesignThemes.Wpf.Converters
77
{
8-
public class NotNullToVisibilityConverter : IValueConverter
8+
public class NullableToVisibilityConverter : IValueConverter
99
{
10+
public Visibility NullValue { get; set; } = Visibility.Collapsed;
11+
public Visibility NotNullValue { get; set; } = Visibility.Visible;
12+
1013
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1114
{
12-
return value != null ? Visibility.Visible : Visibility.Collapsed;
15+
return value == null ? NullValue : NotNullValue;
1316
}
1417

1518
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
<Compile Include="Converters\MathConverter.cs" />
229229
<Compile Include="Converters\MathMultipleConverter.cs" />
230230
<Compile Include="Converters\NotConverter.cs" />
231-
<Compile Include="Converters\NotNullToVisibilityConverter.cs" />
231+
<Compile Include="Converters\NullToVisibilityConverter.cs" />
232232
<Compile Include="Converters\NotZeroToVisibilityConverter.cs" />
233233
<Compile Include="Converters\ShadowConverter.cs" />
234234
<Compile Include="Converters\SizeToRectConverter.cs" />

MaterialDesignThemes.Wpf/PopupBox.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ public DataTemplate ToggleContentTemplate
117117
set { SetValue(ToggleContentTemplateProperty, value); }
118118
}
119119

120+
public static readonly DependencyProperty ToggleCheckedContentProperty = DependencyProperty.Register(
121+
"ToggleCheckedContent", typeof (object), typeof (PopupBox), new PropertyMetadata(default(object)));
122+
123+
/// <summary>
124+
/// Content to display in the toggle when it's checked (when the popup is open). Optional; if not provided the <see cref="ToggleContent"/> is used.
125+
/// </summary>
126+
public object ToggleCheckedContent
127+
{
128+
get { return (object) GetValue(ToggleCheckedContentProperty); }
129+
set { SetValue(ToggleCheckedContentProperty, value); }
130+
}
131+
132+
public static readonly DependencyProperty ToggleCheckedContentTemplateProperty = DependencyProperty.Register(
133+
"ToggleCheckedContentTemplate", typeof (DataTemplate), typeof (PopupBox), new PropertyMetadata(default(DataTemplate)));
134+
135+
/// <summary>
136+
/// Template for <see cref="ToggleCheckedContent"/>.
137+
/// </summary>
138+
public DataTemplate ToggleCheckedContentTemplate
139+
{
140+
get { return (DataTemplate) GetValue(ToggleCheckedContentTemplateProperty); }
141+
set { SetValue(ToggleCheckedContentTemplateProperty, value); }
142+
}
143+
120144
public static readonly DependencyProperty PopupContentProperty = DependencyProperty.Register(
121145
"PopupContent", typeof (object), typeof (PopupBox), new PropertyMetadata(default(object)));
122146

0 commit comments

Comments
 (0)