0

我目前正在开发一个开源虚拟键盘,但有一件事我真的没有开始工作:我想创建一个类似于 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>

谁能帮我 ?

4

1 回答 1

0

你能试试这个吗?

<Grid>
    <Button Content="Enter ⏎"
             />
    <Button Content="K"
             />

基本上它使用U+23CE字符作为Return symbol。当然,任何更花哨的东西,你总是可以创建一个带有自定义图像作为内容的按钮

于 2012-07-22T17:43:24.807 回答