Skip to content

Commit 87e67db

Browse files
committed
you can now customise the On content in Action toggles. fixes #243
1 parent 4026f9d commit 87e67db

File tree

6 files changed

+179
-93
lines changed

6 files changed

+179
-93
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@
145145
ToolTip="MaterialDesignActionToggleButton">
146146
<Image Source="Resources/ProfilePic.jpg"></Image>
147147
</ToggleButton>
148+
<TextBlock Margin="16 0 8 0" VerticalAlignment="Center">Customise On Content:</TextBlock>
149+
<ToggleButton Style="{StaticResource MaterialDesignActionToggleButton}"
150+
ToolTip="MaterialDesignActionLightToggleButton">
151+
<ToggleButton.Content>
152+
<materialDesign:PackIcon Kind="EmoticonSad" />
153+
</ToggleButton.Content>
154+
<materialDesign:ToggleButtonAssist.OnContent>
155+
<materialDesign:PackIcon Kind="EmoticonHappy" />
156+
</materialDesign:ToggleButtonAssist.OnContent>
157+
</ToggleButton>
148158
</StackPanel>
149159
<StackPanel Grid.Row="6" Margin="0 16 0 0" Orientation="Horizontal">
150160
<RadioButton Style="{StaticResource MaterialDesignRadioButton}" Margin="0 0 8 8" VerticalAlignment="Center" IsChecked="True">
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace MaterialDesignThemes.Wpf.Converters
7+
{
8+
public class PointValueConverter : IMultiValueConverter
9+
{
10+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
if (values?.Length == 2 && values[0] != null && values[1] != null)
13+
{
14+
double x, y;
15+
if (double.TryParse(values[0].ToString(), out x) &&
16+
double.TryParse(values[1].ToString(), out y))
17+
18+
return new Point(x, y);
19+
}
20+
21+
return new Point();
22+
}
23+
24+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
25+
{
26+
if (value is Point)
27+
{
28+
var point = (Point) value;
29+
return new object[] { point.X, point.Y };
30+
}
31+
32+
return new object[0];
33+
}
34+
}
35+
}

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
<Compile Include="Converters\NullableDateTimeToCurrentDateConverter.cs" />
239239
<Compile Include="Converters\NullToVisibilityConverter.cs" />
240240
<Compile Include="Converters\NotZeroToVisibilityConverter.cs" />
241+
<Compile Include="Converters\PointValueConverter.cs" />
241242
<Compile Include="Converters\ShadowConverter.cs" />
242243
<Compile Include="Converters\SizeToRectConverter.cs" />
243244
<Compile Include="Converters\TimeToVisibilityConverter.cs" />
@@ -285,6 +286,7 @@
285286
<Compile Include="TextFieldAssist.cs" />
286287
<Compile Include="Converters\TextFieldHintVisibilityConverter.cs" />
287288
<Compile Include="TimePicker.cs" />
289+
<Compile Include="ToggleButtonAssist.cs" />
288290
<Compile Include="ToolTipAssist.cs" />
289291
<Compile Include="RippleAssist.cs" />
290292
<Compile Include="Ripple.cs" />

0 commit comments

Comments
 (0)