Ugrás a tartalomhoz

.NET Programming Technologies

Gergely Kovásznai, Csaba Biró

Eszterházy Károly College

Code-behind class

Code-behind class

It can be observed that when we create our project from the basis of the WPF application template, a .cs or a .vb extension file created with the same name for both of the xaml files.

The aim of the foreground code files to separate the application appearance from the application functionality through the development, as you could read in the introduction.

It becomes available with using the x:Class attribute.


Actually, what happens is that the x:Class attribute tells the XAML parser has to create a new lass with the specified name. In other words the former one creates a Window class called MainWindow from the Window class.

Then the content of the MainWindow.xaml.cs file is the following:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

namespace HelloWorld


    /// <summary>

    /// Interaction logic for MainWindow.xaml

    /// </summary>

    public partial class MainWindow : Window


        public MainWindow()