Reputation:
In VS2015, when we generated new WPF project, it contains App.xaml(.cs). I suppose that it will be an entry point of WPF application. Then App.xaml.cs
becomes like:
...
using System.Windows;
namespace WpfApplication
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Now, I remove inheritance of System.Windows.Application
, still it seems to be working...
- public partial class App : Application
+ public partial class App
So let me ask: App
class does not need to inherit System.Windows.Application
? What is the difference?
thanks.
Upvotes: 2
Views: 429
Reputation: 127543
No it is not required. In your code you have the class defined as partial
, this allows your code and autogenerated code by the compiler to be combined.
In your App.xaml you have
<Application x:Class="WpfApplication.App" ...
This tells the compiler you are creating a object of type Application
with the name WpfApplication.App
so the auto-generated code will include the inherited type class. Once your WpfApplication.App
code is combined with the auto-generated WpfApplication.App
the inheritance is already defined.
Upvotes: 2