Click here to Skip to main content
15,881,172 members
Articles / Desktop Programming / WPF

WPF Gadget Container Control

Rate me:
Please Sign up or sign in to vote.
4.00/5 (13 votes)
6 Mar 2009CPOL3 min read 73.9K   4.7K   51  
A Vista-styled gadget container control.
<Window x:Class="GadgetPrototype.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:GadgetPrototype="clr-namespace:GadgetPrototype"
        xmlns:GadgetLibrary="clr-namespace:GadgetLibrary;assembly=GadgetLibrary"
        xmlns:Weather="clr-namespace:GadgetPrototype.Weather"
        xmlns:Picture="clr-namespace:GadgetPrototype.Picture"
        Background="#4d6a73"
        Title="Window1"
        Height="600"
        Width="800">
    <Window.Resources>
        <Weather:WeatherGadget x:Key="_TestGadget" />
        <Picture:PictureGadget x:Key="_PictureGadget" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0"
              Height="22"
              Name="_MainMenu">
            <Menu.Items>
            <MenuItem Header="Background">
                <MenuItem.Items>
                    <MenuItem Header="Solid Color"
                              x:Name="_SolidColorMenu"
                              Click="_SolidColorMenu_Click" />
                    <MenuItem Header="Abstract"
                              x:Name="_AbstractBackgroundMenu"
                              Click="_AbstractBackgroundMenu_Click" />
                    <MenuItem Header="Nature"
                              x:Name="_NatureBackgroundMenu"
                              Click="_NatureBackgroundMenu_Click" />
                </MenuItem.Items>
            </MenuItem>
                <MenuItem Header="Add Gadget">
                    <MenuItem.Items>
                        <MenuItem Header="Weather"
                                  x:Name="_AddWeatherGadget"
                                  Click="_AddWeatherGadget_Click" />
                        <MenuItem Header="Picture"
                                  x:Name="_AddPictureGadget"
                                  Click="_AddPictureGadget_Click" />
                    </MenuItem.Items>
                </MenuItem>
                </Menu.Items>
        </Menu>
        <GadgetLibrary:SnapCanvas x:Name="_SnapCanvas"
                                  Grid.Row="1"
                                  AllowDragging="True"
                                  SnapThreshold="20"
                                  AllowDragOutOfView="False">
        </GadgetLibrary:SnapCanvas>
    </Grid>
</Window>

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)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
I'm a software developer living in Northampton, UK, and enjoy working with the latest .Net technologies.

Comments and Discussions