You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It supports the development of both Desktop and UWP (Universal Windows Platform) applications, enabling developers to create versatile apps that can run across a wide range of Windows devices, from IoT devices to PCs. Built with performance and reliability in mind, WinUI 3 apps are optimized for smooth and efficient operation, ensuring a responsive user experience.
15
15
16
-
WinUI 3 offers backward compatibility with existing UWP and Windows Forms applications, allowing developers to gradually migrate and modernize their applications. Additionally, WinUI 3 is extensible, supporting custom controls and third-party libraries.
16
+
WinUI 3 is an open-source project, offers backward compatibility with existing UWP and Windows Forms applications, allowing developers to gradually migrate and modernize their applications. Additionally, WinUI 3 is extensible, supporting custom controls and third-party libraries.
17
17
18
-
Windows UI Library 3 is an open-source project, encouraging community contributions and feedback. This approach ensures continuous improvement and alignment with the needs of developers and users.
18
+
In this learning path you will implement a Win UI 3 application, which will perform square matrix multiplication. The idea is to reproduce the same functionality used in [Windows Forms learning path](/learning-paths/laptops-and-desktops/win_forms). You will also be able to measure performance improvements on Arm64 architecture.
19
19
20
-
Finally, WinUI 3 is suitable for a broad range of applications, from enterprise software to interactive media. It stands as a testament to Microsoft's commitment to providing robust, forward-looking tools for Windows application development.
21
-
22
-
In this learning path you will implement the Win UI 3 application, which will perform square matrix multiplication. The idea is to reproduce the same functionality as we used in [Windows Forms learning path](/learning-paths/laptops-and-desktops/win_forms). Similarly, as before, we will demonstrate performance improvements of Arm64 architecture.
23
-
24
-
You can find the companion code [here](https://github.com/dawidborycki/Arm64.WinUIApp.git).
20
+
You can find the complete code used in this learning path [here](https://github.com/dawidborycki/Arm64.WinUIApp.git).
25
21
26
22
## Before you begin
27
-
Before you begin the implementation, it is essential to install Visual Studio 2022 with the following workloads:
23
+
Before you begin the implementation, you will need to install Visual Studio 2022 with the following workloads:
28
24
1. .NET desktop development
29
25
2. Universal Windows Platform development
30
26
3. After selecting these workloads, expand the .NET desktop development group under the Installation details and ensure that the 'Windows App SDK C# Templates' option is selected.
31
27
32
28

33
29
34
-
Then, click the 'Individual components' tab and check the '.NET 6.0 Runtime (Long Term Support)'.
30
+
Then, click the 'Individual components' tab and check '.NET 6.0 Runtime (Long Term Support)'.
35
31
36
32

37
33
38
34
## Create the project
39
-
To start creating your project, open Visual Studio and click 'Create a new project'.
35
+
Open Visual Studio and click 'Create a new project'.
40
36
41
37

42
38
@@ -58,7 +54,7 @@ Your project should now be ready. Next, you will design the view using XAML decl
58
54
## User Interface
59
55
First, you will create four anonymous styles. These styles will control the margins, font size, and font weights of texts displayed in the following controls: TextBlock, NumberBox, Button, and ListBox.
60
56
61
-
In a WinUI 3 application, you define the styles in the App.xaml file. So, open this file and modify it as shown in the following code snippet:
57
+
In a WinUI 3 application, you define the styles in the `App.xaml` file. Open this file and modify it as shown in the following code snippet:
62
58
63
59
```XML
64
60
<?xml version="1.0" encoding="utf-8"?>
@@ -113,16 +109,16 @@ In a WinUI 3 application, you define the styles in the App.xaml file. So, open t
113
109
</Application>
114
110
```
115
111
116
-
There are four style declarations, which differ by the 'TargetType' attribute. This attribute indicates the controls to which the style will be applied. For the TextBlock controls, which represent labels, we modify three properties:
117
-
* Margin: We use a uniform margin of 10, meaning that the control will have the same margin on all four sides (left, top, right, bottom).
118
-
* FontSize: We change the font size to 16.
119
-
* FontWeight: We set the fonts displayed in the TextBlock to be semi-bold.
112
+
There are four style declarations, which differ by the 'TargetType' attribute. This attribute indicates the controls to which the style will be applied. For the TextBlock controls, which represent labels, modify three properties:
113
+
* Margin: You will use a uniform margin of 10, meaning that the control will have the same margin on all four sides (left, top, right, bottom).
114
+
* FontSize: Change the font size to 16.
115
+
* FontWeight: Set the fonts displayed in the TextBlock to be semi-bold.
120
116
121
117
Next, you will declare the following user interface:
122
118
123
119

124
120
125
-
This view uses a tabular layout, comprising five rows and two columns. To create such a layout using XAML, you can use the Grid control. Go ahead and open the MainWindow.xaml file and modify it as follows:
121
+
This view uses a tabular layout, comprising five rows and two columns. To create such a layout using XAML, you can use the Grid control. Open the `MainWindow.xaml` file and modify it as follows:
126
122
127
123
```XML
128
124
<?xml version="1.0" encoding="utf-8"?>
@@ -200,7 +196,7 @@ This view uses a tabular layout, comprising five rows and two columns. To create
200
196
</Window>
201
197
```
202
198
203
-
The declaration above is quite lengthy, so let's break it down. First, we configure the Grid's appearance:
199
+
The declaration above is quite lengthy, so let's break it down. First, you configure the Grid's appearance:
204
200
205
201
```XML
206
202
<Grid.ColumnDefinitions>
@@ -217,9 +213,9 @@ The declaration above is quite lengthy, so let's break it down. First, we config
217
213
</Grid.RowDefinitions>
218
214
```
219
215
220
-
These declarations will create a Grid composed of two columns, each spanning half of the available window's width. Then, we create five rows. The height of the first four rows will be adjusted automatically based on the height of the controls placed in those rows. The last row will occupy the remaining space in the window.
216
+
These declarations will create a Grid composed of two columns, each spanning half of the available window's width. Then, you create five rows. The height of the first four rows will be adjusted automatically based on the height of the controls placed in those rows. The last row will occupy the remaining space in the window.
221
217
222
-
In the first row of the Grid, we put two TextBlock controls:
218
+
In the first row of the Grid, put two TextBlock controls:
223
219
224
220
```XML
225
221
<TextBlockText="Processor architecture" />
@@ -229,7 +225,7 @@ In the first row of the Grid, we put two TextBlock controls:
229
225
230
226
The first control will display the fixed text 'Processor architecture'. The second one will be programmatically modified to display the architecture of the processor, for example, AMD64 or ARM64.
231
227
232
-
The next two controls:
228
+
The next two controls define a fixed label ('Matrix size') and a NumberBox. The NumberBox is configured to allow the user to select a matrix size between 100-500 in steps of 100, with a default value of 100.:
233
229
234
230
```XML
235
231
<TextBlock Grid.Row="1"
@@ -246,9 +242,7 @@ The next two controls:
246
242
SpinButtonPlacementMode="Inline" />
247
243
```
248
244
249
-
define a fixed label ('Matrix size') and a NumberBox. The NumberBox is configured to allow the user to select a matrix size between 100-500 in steps of 100, with a default value of 100.
250
-
251
-
Subsequently, we have the following declarations:
245
+
Subsequently, you have the following declarations:
252
246
253
247
```XML
254
248
<TextBlock Grid.Row="2"
@@ -265,7 +259,7 @@ Subsequently, we have the following declarations:
265
259
SpinButtonPlacementMode="Inline" />
266
260
```
267
261
268
-
Again, the first control is used to display the fixed string 'Execution count'. The second one allows the user to specify the number of executions for the matrix multiplications. Here, we enable the user to select an execution count between 10-100 in steps of 10.
262
+
The first control is used to display the fixed string 'Execution count'. The second one allows the user to specify the number of executions for the matrix multiplications. Here, you enable the user to select an execution count between 10-100 in steps of 10.
269
263
270
264
Finally, the view declares two buttons and one ListBox:
271
265
@@ -290,13 +284,13 @@ Finally, the view declares two buttons and one ListBox:
290
284
* The second button will clear the ListBox.
291
285
* The ListBox will display the time it takes to perform matrix multiplication.
292
286
293
-
## Logic
287
+
## Application Logic
294
288
In this section, you will implement the application's logic. First, create two helper classes:
295
289
296
290
1.**MatrixHelper**: This class implements matrix multiplication following the mathematical formula detailed on [Wikipedia](https://en.wikipedia.org/wiki/Matrix_multiplication).
297
291
2.**PerformanceHelper**: This class provides functionality to measure code execution time.
298
292
299
-
They will serve the same purpose as in the [Windows Forms learning path](/learning-paths/laptops-and-desktops/win_forms), so their detailed description is omitted here.
293
+
They will serve the same purpose as in the [Windows Forms learning path](/learning-paths/laptops-and-desktops/win_forms).
300
294
301
295
Next, you will implement event handlers for the two buttons and additional code to programmatically control the window's appearance.
When the application is running and the user clicks the Start button, the application will read the values from the NumberBox controls (NumberBoxMatrixSize and NumberBoxExecutionCount). These values will be used to set the matrix size and the execution count. Using these values, the application will invoke the MeasurePerformance static method of the PerformanceHelper class to measure the time required to perform matrix multiplication for the given matrix size and execution count. The computation time will then be added to the ListBox. At any point, the user can clear the ListBox by clicking the Clear button.
450
+
When the application is running and the user clicks the Start button, the application will read the values from the NumberBox controls (NumberBoxMatrixSize and NumberBoxExecutionCount). These values will be used to set the matrix size and the execution count. Using these values, the application will invoke the MeasurePerformance static method of the PerformanceHelper class to measure the time required to perform matrix multiplication for the given matrix size and execution count. The computation time will then be added to the ListBox. At any point, the user can clear the ListBox by clicking the Clear button.
0 commit comments