forked from Stopbyte/WPF-Numeric-Spinner-NumericUpDown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumericSpinner.xaml
67 lines (66 loc) · 3.75 KB
/
NumericSpinner.xaml
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
<UserControl x:Class="Stopbyte.Controls.NumericSpinner"
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:Stopbyte.Controls"
mc:Ignorable="d" x:Name="root_numeric_spinner"
d:DesignHeight="32" d:DesignWidth="100">
<UserControl.Resources>
<ControlTemplate x:Key="updown_button_style" TargetType="Button">
<Border x:Name="br" BorderThickness="0" BorderBrush="{DynamicResource ThemeBrushDark}"
Background="{DynamicResource ThemeBrush}" CornerRadius="0">
<ContentPresenter x:Name="cp" TextElement.Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="br" Property="Background" Value="{DynamicResource ThemeBrushActive}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="br" Property="Background" Value="Silver" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="Button">
<Setter Property="Template" Value="{StaticResource updown_button_style}" />
</Style>
</UserControl.Resources>
<Border>
<Border.OpacityMask>
<VisualBrush>
<VisualBrush.Visual>
<Border Background="Black" SnapsToDevicePixels="True"
CornerRadius="4"
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType=Border}}"
Height="{Binding ActualHeight, RelativeSource={RelativeSource FindAncestor, AncestorType=Border}}" />
</VisualBrush.Visual>
</VisualBrush>
</Border.OpacityMask>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="22" />
</Grid.ColumnDefinitions>
<TextBox x:Name="tb_main" x:FieldModifier="private" FontWeight="Medium" FontSize="14" VerticalContentAlignment="Center" Padding="5,1"
Grid.Column="0" Grid.RowSpan="2" Text="0" />
<Button x:Name="cmdUp" x:FieldModifier="private" Grid.Column="1" Grid.Row="0" Width="auto" Height="auto" Click="cmdUp_Click">
<Button.Content>
<Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="Black" Data="M4,0 L0,4 L8,4 z"/>
</Button.Content>
</Button>
<Button x:Name="cmdDown" x:FieldModifier="private" Grid.Column="1" Grid.Row="1" Width="auto" Height="auto" Click="cmdDown_Click">
<Button.Content>
<Path HorizontalAlignment="Center" VerticalAlignment="Center" Fill="Black" Data="M0,0 L8,0 L4,4 z"/>
</Button.Content>
</Button>
<Border BorderBrush="Gray" IsHitTestVisible="False" BorderThickness="1" CornerRadius="4" Grid.RowSpan="2"
Grid.ColumnSpan="2" Padding="0" Margin="0" />
</Grid>
</Border>
</UserControl>