Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Full Screen WPF Application with a Low-Level Keyboard Hook

, 26 Nov 2008
This application displays shapes of random sizes and colors. It's perfect for babies and toddlers who love to sit and press away at the keyboard.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="OptionsButtonUp" TargetType="Rectangle">
        <Setter Property="Fill">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#445566" Offset="0.2" />
                    <GradientStop Color="#000000" Offset="0.7" />
                    <GradientStop Color="#555555" Offset="1.0" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="OptionsButtonOver" TargetType="Rectangle">
        <Setter Property="Fill">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#446688" Offset="0.2" />
                    <GradientStop Color="#222222" Offset="0.7" />
                    <GradientStop Color="#666666" Offset="1.0" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="OptionsButtonDown" TargetType="Rectangle">
        <Setter Property="Fill">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#223344" Offset="0.2" />
                    <GradientStop Color="#000000" Offset="0.7" />
                    <GradientStop Color="#444444" Offset="1.0" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="OptionsButton" TargetType="Button">
        <Setter Property="Margin" Value="10" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
                        <Rectangle x:Name="ButtonRect" RadiusX="10" RadiusY="10"
                                       StrokeThickness="2" Stroke="#555555"
                                       Style="{StaticResource OptionsButtonUp}" />

                        <ContentPresenter x:Name="ButtonContent"
                                              Content="{TemplateBinding Content}"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              TextElement.FontSize="20"
                                              TextElement.Foreground="#C8C8C8"/>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ButtonRect" Property="Style"
                                        Value="{StaticResource OptionsButtonOver}" />
                            <Setter TargetName="ButtonContent" Property="TextElement.Foreground"
                                        Value="#FFFFFF" />
                        </Trigger>
                        
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="ButtonRect" Property="Style"
                                        Value="{StaticResource OptionsButtonDown}" />
                            <Setter TargetName="ButtonContent" Property="TextElement.Foreground"
                                        Value="#AAAAAA" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Barry Dorman
Software Developer
United States United States
Barry Dorman is a software engineer from the Birmingham, AL area. His primary focus is ASP.NET. Barry graduated with a BS in Electrical Engineering from The University of Alabama at Birmingham in 2006. Since then, he has kept himself busy working in the healthcare industry.

| Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 26 Nov 2008
Article Copyright 2008 by Barry Dorman
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid