Windows Presentation Foundation(WPF) is a development framework used to lớn create a desktop application. It is a part of the .NET framework. The WPF has a resolution-independent & vector-based rendering engine which is helpful to khuyễn mãi giảm giá with modern graphics hardware. The latest version of WPF is 4.6
. In this framework, UI of the application is designed in XAML language & Application xúc tích và ngắn gọn is Written in C# programming language.
Bạn đang xem: Wpf c# là gìFeatures of WPF are as following:
Extensible Application Markup Language (XAML)ControlsData BindingLayout2D và 3D graphicsAnimationStylesTemplatesDocumentsMediaTextTypographyWPF Architecture:
The major components of the WPF are PresentationFramework, PresentationCore, Milcore, Common Language Runtime(CLR), User32, Kernel. Milcore is written in unmanaged code in order to enable tight integration with DirectX, which is responsible for display. WPF has fine control over memory & execution. The composition engine in milcore is extremely performance-sensitive and required giving up many advantages of the Common Language Runtime lớn gain performance.
Creating a WPF Application Using Visual Studio 2019Step 1:
xuất hiện Visual Studio và select Create a new project
under the Get started
menu. The Create a new project dialog opens. Select the WPF phầm mềm (.NET Framework)
template and then select Next
The Configure your new project
dialog opens. Enter the project name IntroductionToWPFApplication
và then select Create
Visual Studio creates the project & opens the designer for the mặc định application window named MainWindow.xaml
.Solution Explorer Window:
It is used khổng lồ navigate between all files in Project. For example, if you will select a file from this window then all the properties related khổng lồ this file will be seen property window.Properties Window:
This window is used lớn change the different properties of the selected thành tích in the Solution Explorer. Also, you can change the properties of components or controls that you will add to the App.Compiler Log:
This window displays the error và warning messages.
Xem thêm: Hệ Số Đồng Thời Là Gì ? Nghĩa Của Từ Hệ Số Đồng Thời Trong Tiếng AnhXaml Code Editor:
In this window we can write the xaml code for UI of App.Preview Window:
We can see the preview of the window how the window will look like.You can also reset the window layout by setting it to lớn default. Khổng lồ set the default layout, go to Window -> Reset Window Layout
in Visual Studio Menu.Step 3:
Now to add the controls khổng lồ your WPF application go to lớn Toolbox tab present in the extreme left side of Visual Studio. Here, you can see a danh sách of controls. Khổng lồ access the most commonly used controls go to Common Controls present in the Toolbox tab.Step 4:
Now drag & drop the controls that you needed on created Form. For example, if you can địa chỉ cửa hàng TextBox, ListBox, Button, etc. As shown below. By clicking on the particular control in the preview window you can see & change its properties present in the rightmost corner of Visual Studio.
In the above image, you can see the TextBox is selected và its properties are opened in the rightmost corner. You can change its properties’ values as per the application need. The code of controls will be automatically added in the XAML code editor.Step 5:
to lớn run the program you can use an F5 key or Play button present in the toolbar of Visual Studio. To stop the program you can use the pause button present in the ToolBar. You can also run the program by going to lớn Debug-> Start Debugging thực đơn in the menubar.
If you worked with Windows Forms previously then it will be very easy to lớn work with WPF.Advanatages of WPF:
It uses current standard because it is newerthe developers of the controls will likely be more focused on WPF because it’s XAML makes it easy khổng lồ create và edit your UI và allows the development work to be separated between a designer (XAML) và a programmer(C#).Databinding is used khổng lồ make a clean separation between data and layout.Uses hardware efficiently for drawing the UI, for better performance.It is used khổng lồ make user interfaces for both Windows applications & web applications.