开发者

Custom App class bypassing autogenerated file

When I create Wpf project, I get default App class which is derived from Application.

I want to derive App from my own class (which of course inherits Application), but there is autogenerated App.g.cs file which define that App is derived form Application.

How can I tu开发者_开发问答rn off that autogenerated file?


Change the <Application tag in App.xaml to <local:YourClass xmlns:local="clr-namespace:Your.Namespace"

Alternatively, get rid of App.xaml and create the entire class yourself.


When creating your own class derived from Application set the build action to ApplicationDefinition:

"Identifies the XAML markup file that contains the application definition (a XAML markup file whose root element is Application). ApplicationDefinition is mandatory when Install is true and OutputType is winexe. A WPF application and, consequently, an MSBuild project can only have one ApplicationDefinition."

Extract From msdn link

To turn off the creation of the autogenerated app.g.cs change the build action from "ApplicationDefinition" to "Page" and substitute your own entry point into the app.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜