-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggleButton.xaml
More file actions
97 lines (95 loc) · 6.39 KB
/
Copy pathToggleButton.xaml
File metadata and controls
97 lines (95 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<UserControl x:Class="KeepAwake.ToggleButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:KeepAwake"
mc:Ignorable="d"
d:DesignHeight="90" d:DesignWidth="250" d:Background="#FF3060FF">
<ToggleButton x:Name="toggleButton" Width="{Binding ActualWidth}" Height="{Binding ActualHeight}" Command="{Binding ToggleCommand}" IsChecked="{Binding Checked}" >
<ToggleButton.Resources>
<ResourceDictionary>
<!--
<Color x:Key="ColorUnchecked">#FF0856CF</Color>
<Color x:Key="ColorTextUnchecked">#FFF0F0FF</Color>
<Color x:Key="ColorChecked">#FFF0F0FF</Color>
<Color x:Key="ColorTextChecked">#FF0856CF</Color>
<Color x:Key="ColorShadow">#FF000000</Color>
-->
<Color x:Key="ColorUnchecked">#1e56c3</Color>
<Color x:Key="ColorTextUnchecked">#FFF0F0FF</Color>
<Color x:Key="ColorChecked">#FFF0F0FF</Color>
<Color x:Key="ColorTextChecked">#1e56c3</Color>
<Color x:Key="ColorShadow">#FF000000</Color>
</ResourceDictionary>
</ToggleButton.Resources>
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="IsChecked" Value="{Binding Checked}" />
<Setter Property="Canvas.OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="border" CornerRadius="{Binding CornerRadius}" BorderThickness="0" Background="{TemplateBinding Background}" >
<ContentPresenter Width="{Binding ActualWidth}" Height="{Binding ActualHeight}">
<ContentPresenter.Content>
<Grid Width="{Binding ActualWidth}" Height="{Binding ActualHeight}">
<TextBlock x:Name="CaptionTextShadow" Text="{Binding Caption}" d:Text="ToggleButton" FontFamily="./Assets/#UbuntuSans NF" TextDecorations="None" FontSize="{Binding CaptionFontSize}" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="0,0,0,0" TextAlignment="Center" >
<TextBlock.Effect>
<BlurEffect Radius="8.0" KernelType="Gaussian" />
</TextBlock.Effect>
</TextBlock>
<TextBlock x:Name="CaptionText" Text="{Binding Caption}" d:Text="ToggleButton" FontFamily="./Assets/#UbuntuSans NF" TextDecorations="None" FontSize="{Binding CaptionFontSize}" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="0,0,0,0" TextAlignment="Center" />
</Grid>
</ContentPresenter.Content>
</ContentPresenter>
</Border>
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect ShadowDepth="2" Color="{StaticResource ColorShadow}" BlurRadius="2" />
</Setter.Value>
</Setter>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Checked}" Value="false"/>
</MultiDataTrigger.Conditions>
<Setter Property="Canvas.Background">
<Setter.Value>
<SolidColorBrush Opacity="1.0" Color="{StaticResource ColorUnchecked}" />
</Setter.Value>
</Setter>
<Setter Property="TextBlock.Foreground">
<Setter.Value>
<SolidColorBrush Color="{StaticResource ColorTextUnchecked}" />
</Setter.Value>
</Setter>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Checked}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Canvas.Background">
<Setter.Value>
<SolidColorBrush Opacity="1.0" Color="{StaticResource ColorChecked}" />
</Setter.Value>
</Setter>
<Setter Property="TextBlock.Foreground">
<Setter.Value>
<SolidColorBrush Color="{StaticResource ColorTextChecked}" />
</Setter.Value>
</Setter>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
</ToggleButton>
</UserControl>