|
| 1 | +<UserControl x:Class="ModShardLauncher.Controls.MyToggleButton" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 5 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 6 | + xmlns:local="clr-namespace:ModShardLauncher.Controls" |
| 7 | + mc:Ignorable="d" |
| 8 | + d:DesignHeight="450" d:DesignWidth="800"> |
| 9 | + <Grid Height="40" Background="#1B1926" Name="MyGrid"> |
| 10 | + <Grid.Triggers> |
| 11 | + <EventTrigger RoutedEvent="ToggleButton.Checked"> |
| 12 | + <BeginStoryboard> |
| 13 | + <Storyboard x:Name="setBackground"> |
| 14 | + <ColorAnimation BeginTime="0:0:0" |
| 15 | + Storyboard.TargetProperty="Background.Color" |
| 16 | + Storyboard.TargetName="MyGrid" |
| 17 | + From="#1B1926" |
| 18 | + To="#2C2D39" |
| 19 | + Duration="0:0:0.2"/> |
| 20 | + </Storyboard> |
| 21 | + </BeginStoryboard> |
| 22 | + </EventTrigger> |
| 23 | + <EventTrigger RoutedEvent="ToggleButton.Unchecked"> |
| 24 | + <BeginStoryboard> |
| 25 | + <Storyboard x:Name="resetBackground"> |
| 26 | + <ColorAnimation BeginTime="0:0:0" |
| 27 | + Storyboard.TargetProperty="Background.Color" |
| 28 | + Storyboard.TargetName="MyGrid" |
| 29 | + From="#2C2D39" |
| 30 | + To="#1B1926" |
| 31 | + Duration="0:0:0.2"/> |
| 32 | + </Storyboard> |
| 33 | + </BeginStoryboard> |
| 34 | + </EventTrigger> |
| 35 | + </Grid.Triggers> |
| 36 | + <TextBlock Grid.Row="1" Grid.Column="0" Margin="72,0,0,0" |
| 37 | + Text="{Binding Path=Text, RelativeSource={RelativeSource AncestorType=local:MyToggleButton}}" |
| 38 | + Foreground="White" FontSize="22" Background="Transparent" |
| 39 | + HorizontalAlignment="Left" VerticalAlignment="Center"> |
| 40 | + </TextBlock> |
| 41 | + <ToggleButton x:Name="MyButton" Grid.Column="0" VerticalAlignment="Center" |
| 42 | + HorizontalAlignment="Left" Margin="16,0,0,0" |
| 43 | + Height="32" Width="32" BorderThickness="0" |
| 44 | + Checked="MyButton_Checked"> |
| 45 | + <ToggleButton.Style> |
| 46 | + <Style TargetType="{x:Type ToggleButton}"> |
| 47 | + <Setter Property="Template"> |
| 48 | + <Setter.Value> |
| 49 | + <ControlTemplate TargetType="{x:Type ToggleButton}"> |
| 50 | + <Border x:Name="border" BorderThickness="{TemplateBinding BorderThickness}" |
| 51 | + Background="{TemplateBinding Background}" SnapsToDevicePixels="True"> |
| 52 | + |
| 53 | + </Border> |
| 54 | + <ControlTemplate.Triggers> |
| 55 | + <Trigger Property="IsMouseOver" Value="True"> |
| 56 | + <Setter Property="Background" TargetName="border" Value="{DynamicResource OverSource}"/> |
| 57 | + <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource OverSource}"/> |
| 58 | + </Trigger> |
| 59 | + <Trigger Property="IsPressed" Value="True"> |
| 60 | + <Setter Property="Background" TargetName="border" Value="{DynamicResource DownSource}"/> |
| 61 | + <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource DownSource}"/> |
| 62 | + </Trigger> |
| 63 | + </ControlTemplate.Triggers> |
| 64 | + </ControlTemplate> |
| 65 | + </Setter.Value> |
| 66 | + </Setter> |
| 67 | + </Style> |
| 68 | + </ToggleButton.Style> |
| 69 | + <ToggleButton.Background> |
| 70 | + <ImageBrush ImageSource="{Binding Path=ImageSource, RelativeSource={RelativeSource AncestorType=local:MyToggleButton}}"/> |
| 71 | + </ToggleButton.Background> |
| 72 | + </ToggleButton> |
| 73 | + </Grid> |
| 74 | +</UserControl> |
0 commit comments