Skip to content

Commit 3b429e6

Browse files
authored
Update how-to-1.md
1 parent edeff50 commit 3b429e6

File tree

1 file changed

+21
-27
lines changed
  • content/learning-paths/laptops-and-desktops/win_winui3

1 file changed

+21
-27
lines changed

content/learning-paths/laptops-and-desktops/win_winui3/how-to-1.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,26 @@ WinUI 3 incorporates Microsoft's Fluent Design System, which emphasizes intuitiv
1313

1414
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.
1515

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.
1717

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.
1919

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).
2521

2622
## 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:
2824
1. .NET desktop development
2925
2. Universal Windows Platform development
3026
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.
3127

3228
![fig1](Figures/01.png)
3329

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)'.
3531

3632
![fig2](Figures/02.png)
3733

3834
## 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'.
4036

4137
![fig3](Figures/03.png)
4238

@@ -58,7 +54,7 @@ Your project should now be ready. Next, you will design the view using XAML decl
5854
## User Interface
5955
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.
6056

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:
6258

6359
```XML
6460
<?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
113109
</Application>
114110
```
115111

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.
120116

121117
Next, you will declare the following user interface:
122118

123119
![fig6](Figures/06.png)
124120

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:
126122

127123
```XML
128124
<?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
200196
</Window>
201197
```
202198

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:
204200

205201
```XML
206202
<Grid.ColumnDefinitions>
@@ -217,9 +213,9 @@ The declaration above is quite lengthy, so let's break it down. First, we config
217213
</Grid.RowDefinitions>
218214
```
219215

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.
221217

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:
223219

224220
```XML
225221
<TextBlock Text="Processor architecture" />
@@ -229,7 +225,7 @@ In the first row of the Grid, we put two TextBlock controls:
229225

230226
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.
231227

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.:
233229

234230
```XML
235231
<TextBlock Grid.Row="1"
@@ -246,9 +242,7 @@ The next two controls:
246242
SpinButtonPlacementMode="Inline" />
247243
```
248244

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:
252246

253247
```XML
254248
<TextBlock Grid.Row="2"
@@ -265,7 +259,7 @@ Subsequently, we have the following declarations:
265259
SpinButtonPlacementMode="Inline" />
266260
```
267261

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.
269263

270264
Finally, the view declares two buttons and one ListBox:
271265

@@ -290,13 +284,13 @@ Finally, the view declares two buttons and one ListBox:
290284
* The second button will clear the ListBox.
291285
* The ListBox will display the time it takes to perform matrix multiplication.
292286

293-
## Logic
287+
## Application Logic
294288
In this section, you will implement the application's logic. First, create two helper classes:
295289

296290
1. **MatrixHelper**: This class implements matrix multiplication following the mathematical formula detailed on [Wikipedia](https://en.wikipedia.org/wiki/Matrix_multiplication).
297291
2. **PerformanceHelper**: This class provides functionality to measure code execution time.
298292

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).
300294

301295
Next, you will implement event handlers for the two buttons and additional code to programmatically control the window's appearance.
302296

@@ -453,4 +447,4 @@ private void ButtonClear_Click(object sender, RoutedEventArgs e)
453447
}
454448
```
455449

456-
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

Comments
 (0)