Saturday 7 March 2009

Base classes for WPF

Here is an example of how to implement base classes for Windows in wpf

BaseWindow.cs
using System.Windows;
namespace PartnerRe.WPF.Utilities
{
public class BaseWindow : Window
{
public BaseWindow()
{
this.ShowInTaskbar = false;
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
System.Drawing.Color color = System.Drawing.SystemColors.Control;
this.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(color.R, color.G, color.B));
}
protected override void OnInitialized(System.EventArgs e)
{
base.OnInitialized(e);
}
}
}

src:BaseWindow x:Class="WinMyWindow"
...
xmlns:src="clr-namespace:PartnerRe.WPF.Utilities;assembly=MyUtilities"
...
/src:BaseWindow