Using GlassWindow(WPF) and GlassForm(Win Forms) in Vista Bridge 1.4
For starters,
The Vista Bridge Sample Library contains source code for assemblies that provide managed code developers access to Windows Vista features that are not available in the .NET Framework. Some of the features included in the Vista Bridge Sample Library are - Vista style Task and File Dialogs, Common Open and Save dialogs, Application Recovery and Restart, Known Folders, Network Lists, Power Management, User Account Control, CommandLink control, Aero Wizard Control, System provided icons etc.
Vista Bridge 1.4 can be downloaded from Vista Bridge Sample Library 1.4.
Vista Bridge 1.4 has two new classes GlassWindow and GlassForm which enable users to write Aero aka Glass enabled WPF and Windows applications. GalssWindow class is for WPF applications and GlassForm is intended for windows applications. In windows applications inheriting from different base class instead of default System.Windows.Forms.From is straight forward. You can just do some thing like “public partial class Form1 : GlassForm” and it will just work fine. But it is not the same with WPF xaml windows. You cannot just inherit from a custom Window class, instead you have modify both the code behind and the xaml too.
He is an example of implementation of GalssWindow for WPF applications from VistaBridge
<src:GlassWindow x:Class="Window1"
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:Microsoft.SDK.Samples.VistaBridge.Dialogs;assembly=VistaBridgeLibrary"
Title="DWM Manager Demo App" Height="435" Width="506">
<Grid>
<Button Margin="12,193,160,181" Name="ActivateGlassButton" Click="ActivateGlassButton_Click">Activate Glass</Button>
<Button Height="23" Margin="12,0,160,152" Name="ExtendFrameButton" VerticalAlignment="Bottom" Click="ExtendFrameButton_Click">Extend
Frame Into Client Area</Button>
</Grid>
</src:GlassWindow>
and in the code behind window.xaml.cs…
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : GlassWindow
{
public Window1()
{
InitializeComponent();
}
private void ActivateGlassButton_Click(object sender, RoutedEventArgs e)
{
// Set the background to transparent from the WPF perspective
this.Background = Brushes.Transparent;
this.IsGlassEnabled = true;
}
private void ExtendFrameButton_Click(object sender, RoutedEventArgs e)
{
this.FrameThickness = new Thickness(0, 45, 0, 0);
}
}
Here is the Sample implementation for Winforms application
You do not have to change anything in the .design file. Just in the code behind Form1.cs.
public partial class Form1 : Form GlassForm
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.IsGlassEnabled = !this.IsGlassEnabled;
}
private void button2_Click(object sender, EventArgs e)
{
this.FormThickness = new Padding(0, 45, 0, 0);
}
}
and do not forget to include below libraries for both WPF and Winform applications. (You should add Vista Bridge Libraries and references to get these working)
using Microsoft.SDK.Samples.VistaBridge.Library;
using Microsoft.SDK.Samples.VistaBridge.Dialogs;
Comments
- Anonymous
February 18, 2009
PingBack from http://www.clickandsolve.com/?p=10610