0

I am developing an open source virtual keyboard at the moment but there's one thing i really dont get to work: I want to create a Enter button like the one on the windows osk. but how can i make WPF drawing this as a button ?

And here's my code for the buttons:

 <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>

Can anyone help me ?

H.B.
  • 166,899
  • 29
  • 327
  • 400

1 Answers1

0

Can you try this ?

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

Basically it is using the U+23CE character for Return symbol. Of course anything more fancy you can always create an button with a custom image as content

parapura rajkumar
  • 24,045
  • 1
  • 55
  • 85