views:

44

answers:

1

Hi,

I'm not even sure if this is even possible, but I've just started WPF development on a few new projects and tried to wrap up some common functionality by creating a mini-framework. Just things like exception handling and thread management.

What I would like to do is replace this line...

public partial class App : Application

with

public partial class App : MyFrameworkApplication

I've got the libraries set up and referenced, but I get an error regarding the 'partially' declared App class, presumably because it's still referencing the old base class.

Any ideas? Thanks.

EDIT: @Jeff M: No, your solution didn't work. I suspect because the MyFrameworkApplication is actually in a library and the z namespace declaration fails to recognise the library's namespace. I've got it referenced in the App.xaml.cs, but the suspicious looking error is:

Error 3 Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'MyLibraryNamespace' that is not included in the assembly.

I can circumvent the problem by creating a proxy class within the local namespace and having it derive from the library class...but it's a bit smelly.

+4  A: 

I suspect it's because the the underlying XAML root is still an Application as opposed to MyFrameworkApplication. I'd guess the generated baml uses the root as it's parent class. Try changing it to the appropriate names.

e.g.,

<z:MyFrameworkApplication x:Class="MyNamespace.App"
             ...
             xmlns:z="clr-namespace:MyNamespace">
    ...
</z:MyFrameworkApplication>

It seems my suspicions were correct.

Code-behind, Event Handler, and Partial Class Requirements in WPF

The partial class must derive from the type that backs the root element.

Jeff M
I will accept this once I've had a chance to check :)
acron
Finally got it! The CLR string I needed was: `xmlns:x="clr-namespace:MyLibraryNamespace;assembly=MyLibraryNamespace"`
acron