我目前正在开发一个开源虚拟键盘,但有一件事我真的没有开始工作:我想创建一个类似于 windows osk 上的 Enter 按钮。但是我怎样才能让 WPF 把它画成一个按钮呢?
这是我的按钮代码:
<Style x:Key="EnterButton" BasedOn="{StaticResource KeyboardButton}" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Rectangle Fill="{TemplateBinding Background}" Stroke="#FF000000" StrokeThickness="1" RadiusX="5" RadiusY="50" Height="68" HorizontalAlignment="Center" x:Name="rectangle" VerticalAlignment="Top" Width="100"/>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="UIElement.PreviewMouseLeftButtonDown">
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.0500000" Value="0.18"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UIElement.PreviewMouseLeftButtonUp">
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.18"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.0500000" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
谁能帮我 ?