65.9K
CodeProject is changing. Read more.
Home

Windows7 / VS2010 / WPF 4 Demo App

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Nov 27, 2009

CPOL

1 min read

viewsIcon

17800

Windows7 / VS2010 / WPF 4 demo app

The other day, I finished up a small demo app that I was writing over at www.codeproject.com which covers several of the new Windows7 features such as TaskBars/JumpLists.

The finished article looks like this:

45178/start2_thumb.jpg

45178/start4_thumb.jpg

45178/start5_thumb.jpg

45178/task_thumb.jpg

The idea behind this demo app is actually very simple, I wanted to show how to use the Managed Extensibility Framework (MEF) to add in a bunch of Pixel Shaders that were inside a separate assembly. I also use some of the new .NET 4.0 goodies such as Dynamic and ExpandoObject.

The demo app also show cases how to use the new System.Windows.Shell namespace.

In case you are wondering, here is how you would create a JumpList using the new System.Windows.Shell namespace.

JumpList jumpList = new JumpList();
JumpList.SetJumpList(Application.Current, jumpList);

JumpTask jumpTask = new JumpTask();
jumpTask.Title = "IE";
jumpTask.CustomCategory =
    "Keep Notes";
jumpTask.ApplicationPath =
    @"C:\Program Files\Internet Explorer\iexplore.exe";
String systemFolder =
    Environment.GetFolderPath(
        Environment.SpecialFolder.System);
jumpTask.IconResourcePath =
    @"C:\Program Files\Internet Explorer\iexplore.exe";
jumpTask.IconResourceIndex = 0;
jumpTask.Arguments = "pixel shaders";
jumpList.JumpItems.Add(jumpTask);
jumpList.Apply();

And here is how you can create a TaskBar that can interact with your application code, again using the new System.Windows.Shell namespace.

<Window x:Class="MefFX.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MefFX" Height="600" Width="800">

    <Window.TaskbarItemInfo>
        <TaskbarItemInfo
            ProgressState="Normal"
            Description="Some text"
            ThumbnailClipMargin=
        "{Binding RelativeSource=
            {RelativeSource FindAncestor,
                    AncestorType={x:Type Window}},
            Path=BorderThickness}">
            <TaskbarItemInfo.ThumbButtonInfos>
                <ThumbButtonInfo
                   Click="SearchForPixelShadersInside_Click"
                    DismissWhenClicked="False"
                    ImageSource="Images/ie.png" />
                <ThumbButtonInfo Command="{Binding AboutCommand}"
                    DismissWhenClicked="False"
                    ImageSource="Images/about.png" />
            </TaskbarItemInfo.ThumbButtonInfos>
        </TaskbarItemInfo>

    </Window.TaskbarItemInfo>

....
....
....
....

</Window>

This TaskBar is obviously done in WPF4.0 using XAML but it would be easy enough to do in WinForms using the TaskbarItemInfo class which is in the new System.Windows.Shell namespace.

Anyway, the full article explains all this and a lot more in a lot more detail, so if you feel inclined to have a read through of that, the full article is available over at this link:

Enjoy!