App.xaml, where are you?

I am new to WPF. Created a new UserControl WPF. See some people use the app.xaml file to set application-level internal resources.

My solution consists of WinForm and WPF UserControl. I do not see the app.xaml file anywhere.

How to act?

+5
source share
5 answers

App.xaml is associated with the WPF application. If you have only UserControl, there is no application for its participation, is there?

Build a WPF application and you will have App.xaml to host application-level resources.

Of interest, why do you have WinForm if you use a WPF user control?

EDIT: : WPF Application , WPF.

EDIT: , , , , . , - .

+4

WPF Silverlight WPF Winforms

+3

WinForm, app.xaml.

WPF.

+3

This article explains in detail how to use application resources in a deployment / interaction scenario:

http://drwpf.com/blog/2007/10/05/managing-application-resources-when-wpf-is-hosted/

The solution path that I chose (from the article) should include App.xaml as a page element

Edit project file:

<Page Include="App.xaml" />
<Compile Include="App.xaml.cs">
  <DependentUpon>App.xaml</DependentUpon>
  <SubType>Code</SubType>
</Compile>

Add code:

public App()
{
    InitializeComponent();
}

public static void EnsureApplicationResources()
{
    if (Application.Current == null)
    {
        // create the Application object
        new App();
    }
}

Full information is given in the article.

+2
source

All Articles