views:

35

answers:

1
+2  A: 

That would be in the declaration of myWindow itself - the designer will be generating the other half of the partial type based on the XAML, based on your element type.

You can use an element of <mySubclassedWindow> instead, so long as you give it the appropriate namespace and assembly references.

EDIT: Okay, so here's a short example, in a project called WpfApplication. My Window subclass:

using System.Windows;

namespace WpfApplication
{
    public class EnhancedWindow : Window
    {
    }
}

My XAML:

<y:EnhancedWindow x:Class="WpfApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:y="clr-namespace:WpfApplication"
        Title="MainWindow" Height="350" Width="525">
</y:EnhancedWindow>

My partial type:

namespace WpfApplication
{
    public partial class MainWindow : EnhancedWindow
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

It all builds with no problem. I think that's what you wanted to do, right?

Jon Skeet
thanks Jon, do you mean the <Window part at the very beginning of file? how can i modify that to use the subclassed version?
Sonic Soul
@Sonic: Yes, that's what I mean. And you'd need to modify it to refer to your subclassed type instead of `Window`. I'm just trying to come up with a short demonstration...
Jon Skeet