Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In WPF force App to inherit from a class defferent from System.Windows.Application

Tags:

c#

.net

wpf

I want to change App's base class to inherit from my own class in a class library. It is already like this:

public partial class App : System.Windows.Application

Now I want to change it to

public partial class App : MainModule.App

whère MainModule.App is in a class library. When I change it, App.g.i.cs doesn't let me because it inherits from System.Windows.Application . When I change App.g.i.cs after compiling it goes back to its default: System.Windows.Application. Is there any way to force App class to inherit from my class?.

Note that MainModule.App inherits from System.Windows.Application.

like image 619
Mohammad Mirmostafa Avatar asked Sep 04 '25 01:09

Mohammad Mirmostafa


1 Answers

I did it. I did 2 works: 1- I changed MainModule.App to MainModule.MyApp. 2- I changed App.xaml to:

<mainModule:MyApp x:Class="FrontOffice.XBAP.App"
...
xmlns:mainModule="clr-namespace:MainModule;assembly=MainModule">

It's now working.

like image 169
Mohammad Mirmostafa Avatar answered Sep 07 '25 11:09

Mohammad Mirmostafa