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.
I suspect it’s because the the underlying XAML root is still an
Applicationas opposed toMyFrameworkApplication. I’d guess the generated baml uses the root as it’s parent class. Try changing it to the appropriate names.e.g.,
It seems my suspicions were correct.
From the docs in Code-Behind and XAML in WPF:
The root application type in code-behind and in the xaml must agree.