Question Where can I find out more about a WPF program flow?

failedtofail

Member
Joined
Jun 16, 2022
Messages
20
Programming Experience
Beginner
A weakspot I still have is not understanding completely the program flow of a C# WPF application. So for example when I press the START button in Visual Studio what exactly happens? What exactly is the starting point? Is it always where the static void Main() method resides? Does InitializeComponent() have to be part of this method? So the program executes whatever is in Main method and stops when it is done?

I understand that there is user input involved and based on the user input the flow control changes. But there must be an overarching flowchart which embodies the essentials of the program flow.

Where can I find a good BASIC explanation for this?

Thanks.
 
Found with "WPF lifecycle" in Google.


 
Ok, been reading through a few times, thanks again for the link Skydiver.

Article says the following:

Quote: Visual Studio derives a custom class from the Application class.

C#:
]<Application x:Class="TestApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml"
>
</Application>

The starting point is a XAML template, which is named App.xaml by default."

"The Class attribute is used in XAML to create a class derived from the element. Thus, this class creates a class that derives from Application, with the name TestApplication.App in the above example. The application tag not only creates a custom application class, but it also sets the StartupUri property to identify the XAML document that represents the main window."


Unquote:

I created a new project and called it WPFLifeCycleProject with the VS Solution Explorer attached.

Q1 – is the class derived from the App.xaml class WPFLifeCycleProject.App.xaml.cs, i.e. is WPFLifeCycleProject.App.xaml.cs that equivalent to TestApplication.App?

In App.xaml x:Class="WPFLifeCycleProject.App" but I don't see any WPFLifeCycleProject.App.cs class in the Solution Explorer - so confusing.

Q2 – must WPFLifeCycleProject.App.xaml.cs this derived class have the InitializeComponent() method in order for the application to work correctly, i.e does the x:Class attribute specify the class with the InitializeComponent() method?

Thanks.
 

Attachments

  • Solution Explorer 18-Jul-22.png
    Solution Explorer 18-Jul-22.png
    15.8 KB · Views: 2
Back
Top Bottom