Archive for the Category WPF

 
 

Shaped Windows in WPF

In previous versions of Microsoft .Net Framework, creating shaped windows was a time-consuming process that involved Win API calls.Not anymore - one of the modern  aspects of WPF is that you can make  non-rectangular windows in simple way.Creating shaped forms works in the following manner.First, you create an image, which, when we are finished, will act as your window.  Second, you change a XAML to make this image become the form.

  • Create a transparent image file that will be used to set the desired shape of the window.

  • Create a Windows Application(WPF) project and add the image control to it.Remember to make the window transparent as shown in code below
<Window x:Class="WindowsApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WindowsApplication1" Height="300" Width="300"
    AllowsTransparency="True"
    WindowStyle="None"
    Background="Transparent" 
    >
    <Grid>
    <Image  Name="image1" />
  </Grid>
</Window>

 

  • Add code that recreates the functionality that the title bar provided, such as moving the window and closing it.
using System;
using System.Windows.Input;
using System.Windows.Media.Imaging;
 
 
namespace WindowsApplication1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : System.Windows.Window
{
    public Window1()
    {
        InitializeComponent();
 
        image1.Source = new BitmapImage(
 
            new Uri(@"C:\Documents and Settings\username\Desktop\Untitled.png"));
    }
 
 
    protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
    {
        base.OnMouseLeftButtonDown(e);
        DragMove();
    }
 
 
 
    protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
    {
        base.OnMouseRightButtonDown(e);
 
        Close();
    }
 
}
}
 
Technorati Tags: WPF, XAML, dotnet

WPF on steroids - Outlook clone

Two engineer from the Switzerland branch of Microsoft Ronnie Saurenmann and  Ruihua Jin developed an Outlook clone using WPF, XAML, Expression Blend etc.
The online demonstration(XPAB) is available at this url. Check out the 90 pages tutorial about how you can develop an application similar to MS Outlook(be sure to download the project files).

A Spy++ like utility for WPF applications

Take a look at a tool called Snoop that I found useful while developing and debugging WPF Applications.

Features

  • Browse the visual tree of running WPF applications.
  • Inspect properties of elements at runtime.
  • Edit properties of elements at runtime.
  • Inspect RoutedEvents that are occurring, including the elements that handle them.
  • Magnify sections of the User Interface.
  • Locate and debug binding bugs.

 

 

Documentation
Download

Technorati tags: WPF, XAML, dotnet


Page 2 of 212