WPF 数字小键盘Themes
![](http://images0.cnblogs.com/blog/565893/201312/03133024-1762e2fb0ff84a09a5fff6f4c28ea045.png)
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TouchKeyboard.Keyboard" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Style x:Key="MyFocusVisual"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Control}"> <Grid Margin="4 2"> <Rectangle x:Name="r1" StrokeThickness="1" Stroke="Black" StrokeDashArray="2 2"/> <Border x:Name="border" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" CornerRadius="2" BorderThickness="1" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="ShadowStyle"> <Setter Property="Control.Foreground" Value="LightGray" /> </Style> <Style x:Key="InformButton" TargetType="{x:Type Button}"> <Setter Property="OverridesDefaultStyle" Value="True"/> <Setter Property="Margin" Value="2"/> <Setter Property="FontFamily" Value="Verdana"/> <Setter Property="FontSize" Value="18px"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="FocusVisualStyle" Value="{StaticResource MyFocusVisual}" /> <Setter Property="Background" > <Setter.Value> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" > <GradientStop Color="#FF0EFF1D" Offset="0.059"/> <GradientStop Color="#FFF7FFF7" Offset="1"/> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="border" BorderThickness="1" Padding="4,2" CornerRadius="3" Height="Auto" Width="Auto" SnapsToDevicePixels="False" BorderBrush="#FF858585"> <Border.Effect> <DropShadowEffect BlurRadius="0" Direction="270" ShadowDepth="2" Opacity="0.425" RenderingBias="Quality"/> </Border.Effect> <Border.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#FFCECECE" Offset="1"/> <GradientStop Color="#FFF7FFF7"/> </LinearGradientBrush> </Border.Background> <Grid > <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="contentShadow" Style="{StaticResource ShadowStyle}"/> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="content"/> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="border" Property="BorderBrush" Value="#FF4788c8" /> <Setter Property="Foreground" Value="#FF4788c8" /> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Background" > <Setter.Value> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" > <GradientStop Color="#FFFFD190" Offset="0.50"/> <GradientStop Color="Orange" Offset="0.95"/> <GradientStop Color="#FFFFD190" Offset="1"/> </LinearGradientBrush> </Setter.Value> </Setter> <Setter TargetName="content" Property="RenderTransform" > <Setter.Value> <TranslateTransform Y="1.0" /> </Setter.Value> </Setter> </Trigger> <Trigger Property="IsDefaulted" Value="True"> <Setter TargetName="border" Property="BorderBrush" Value="#FF282828" /> </Trigger> <Trigger Property="IsFocused" Value="True"> <Setter TargetName="border" Property="BorderBrush" Value="#FF282828" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="border" Property="Opacity" Value="0.7" /> <Setter Property="Foreground" Value="Gray" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type local:TouchScreenKeyboard}"> <Setter Property="Background" Value="White"/> <Setter Property="Width" Value="245"/> <Setter Property="Height" Value="245"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:TouchScreenKeyboard}"> <Border CornerRadius="5" Focusable="False" BorderBrush="{x:Null}" BorderThickness="1"> <Border BorderBrush="{x:Null}" BorderThickness="1" CornerRadius="5"> <Border.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FFDADADA" Offset="0.442"/> <GradientStop Color="#FFEFEFEF"/> <GradientStop Color="#FFEDEDED" Offset="1"/> </LinearGradientBrush> </Border.Background> <Border BorderThickness="1,1,1,5" CornerRadius="5"> <Border.BorderBrush> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0.809"> <GradientStop Color="#FF4E4E4E" Offset="0.638"/> <GradientStop Color="#FFCCCCCC" Offset="1"/> </LinearGradientBrush> </Border.BorderBrush> <Border BorderBrush="{x:Null}" BorderThickness="2,4,2,0" CornerRadius="5" Padding="5"> <StackPanel Orientation="Vertical"> <StackPanel Orientation="Horizontal" > <Button Command="local:TouchScreenKeyboard.Cmd1" Style="{StaticResource InformButton}" Width="50" Height="50" Content="1"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd2" Width="50" Height="50" Content="2"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd3" Width="50" Height="50" Content="3"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.CmdBackspace" Width="50" Height="50" Content="回删"/> </StackPanel> <StackPanel Orientation="Horizontal"> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd4" Width="50" Height="50" Content="4"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd5" Width="50" Height="50" Content="5"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd6" Width="50" Height="50" Content="6"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.CmdClear" Width="50" Height="50" Content="清空"/> </StackPanel> <StackPanel Orientation="Horizontal"> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd7" Width="50" Height="50" Content="7" /> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd8" Width="50" Height="50" Content="8"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd9" Width="50" Height="50" Content="9"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.CmdEnter" Width="50" Height="50" Content="确定"/> </StackPanel> <StackPanel Orientation="Horizontal"> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.Cmd0" Width="50" Height="50" Content="0"/> <Button Style="{StaticResource InformButton}" Command="local:TouchScreenKeyboard.CmdGreaterThan" Width="50" Height="50" Content="."/> <Button Style="{StaticResource InformButton}" Width="104" Height="50" Content=" iEvent~" FontSize="20"/> </StackPanel> </StackPanel> </Border> </Border> </Border> </Border> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="Opacity" Value="0.98"/> </Style> </ResourceDictionary>