Skip to content

Commit 4a88557

Browse files
committed
docs: formatting tweaks
1 parent 51f4d39 commit 4a88557

File tree

1 file changed

+57
-49
lines changed

1 file changed

+57
-49
lines changed

hub/apps/get-started/uno-simple-photo-viewer.md

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ After you've [created](/hub/apps/get-started/simple-photo-viewer-winui3.md) a st
2727
- .NET desktop development installed (for Gtk, Wpf, and Linux Framebuffer development)
2828
:::image type="content" source="../images/uno/uno-vs-install-dotnet.png" alt-text="dotnet desktop workload in VS":::
2929

30-
31-
3230
[!INCLUDE [uno-setup.md](./uno-setup.md)]
3331

3432
## Install the Uno Platform solution templates
@@ -59,9 +57,9 @@ Create a new C# solution using the **Uno Platform App** type from Visual Studio'
5957

6058
:::image type="content" source="images/uno/uno-configure-project.png" alt-text="Specify project details":::
6159

62-
Now you'll choose a base template to take your Simple Photo gallery application multi-platform.
60+
Now you'll choose a base template to take your Simple Photo gallery application multi-platform.
6361

64-
The Uno Platform App template comes with two preset options that allow you to quickly get started with either a **Blank** solution or the **Default** configuration which includes references to the Uno.Material and Uno.Toolkit libraries. The Default configuration also includes Uno.Extensions which is used for dependency injection, configuration, navigation, and logging, and it uses MVUX in place of MVVM, making it a great starting point for rapidly building real-world applications.
62+
The Uno Platform App template comes with two preset options that allow you to quickly get started with either a **Blank** solution or the **Default** configuration which includes references to the Uno.Material and Uno.Toolkit libraries. The Default configuration also includes Uno.Extensions which is used for dependency injection, configuration, navigation, and logging, and it uses MVUX in place of MVVM, making it a great starting point for rapidly building real-world applications.
6563

6664
:::image type="content" source="../images/uno/uno-vsix-new-project-options.png" alt-text="Uno solution template for project startup type":::
6765

@@ -86,11 +84,11 @@ For more information on creating the `Assets` folder and adding images to it, se
8684

8785
## Preparing your app
8886

89-
Now that you've generated the functional starting point of your multi-platform WinUI application, you can copy code into it from the desktop project.
87+
Now that you've generated the functional starting point of your multi-platform WinUI application, you can copy code into it from the desktop project.
9088

9189
### Copy the view
9290

93-
Because Uno Platform allows you to use the XAML flavor you're already familiar with, you can copy over the same code you created in the [previous tutorial](/hub/apps/get-started/simple-photo-viewer-winui3.md).
91+
Because Uno Platform allows you to use the XAML flavor you're already familiar with, you can copy over the same code you created in the [previous tutorial](/hub/apps/get-started/simple-photo-viewer-winui3.md).
9492

9593
Return to the **SimplePhotos** project from the previous tutorial. In the **Solution Explorer**, find the file named `MainWindow.xaml` and open it. Observe that the contents of the view are defined within a `Window` element rather than a `Page`. This is because the desktop project is a WinUI 3 application, which can use `Window` elements to define the contents of the view:
9694

@@ -143,8 +141,10 @@ Return to the **SimplePhotos** project from the previous tutorial. In the **Solu
143141

144142
<Style x:Key="ImageGridView_ItemContainerStyle"
145143
TargetType="GridViewItem">
146-
<Setter Property="Background" Value="Gray"/>
147-
<Setter Property="Margin" Value="8"/>
144+
<Setter Property="Background"
145+
Value="Gray"/>
146+
<Setter Property="Margin"
147+
Value="8"/>
148148
</Style>
149149

150150
<ItemsPanelTemplate x:Key="ImageGridView_ItemsPanelTemplate">
@@ -237,10 +237,10 @@ Uno Platform's multi-platform implementation of the controls found in the `Windo
237237
</Page>
238238
```
239239

240-
Recall that the desktop solution also had a `MainWindow.xaml.cs` file that contained code-behind which corresponds to the view. In the Uno Platform project, the code-behind for the `MainPage` view we've copied into is contained in the `MainPage.xaml.cs` file.
240+
Recall that the desktop solution also had a `MainWindow.xaml.cs` file that contained code-behind which corresponds to the view. In the Uno Platform project, the code-behind for the `MainPage` view we've copied into is contained in the `MainPage.xaml.cs` file.
241241

242242
To bring this code-behind multi-platform, we should first move the following into the `MainPage.xaml.cs` file:
243-
243+
244244
- `Images` property: Provides the `GridView` with an observable collection of image files
245245

246246
- Contents of the constructor: Calls `GetItemsAsync()` to populate the `Images` collection with items representing image files
@@ -270,9 +270,9 @@ public sealed partial class MainPage : Page
270270
public ObservableCollection<ImageFileInfo> Images { get; }
271271
= new ObservableCollection<ImageFileInfo>();
272272

273-
public MainPage()
274-
{
275-
this.InitializeComponent();
273+
public MainPage()
274+
{
275+
this.InitializeComponent();
276276
GetItemsAsync();
277277
}
278278

@@ -333,22 +333,27 @@ public sealed partial class MainPage : Page
333333
> [!NOTE]
334334
> The files in your Uno app project should use `UnoSimplePhotos` as the namespace.
335335
336-
So far, the files for the main view we're working with contain all the capabilities of the desktop solution. After we copy over the `ImageFileInfo.cs` model file, we will learn how to modify the desktop-oriented blocks of code for multi-platform compatibility.
336+
So far, the files for the main view we're working with contain all the capabilities of the desktop solution. After we copy over the `ImageFileInfo.cs` model file, we will learn how to modify the desktop-oriented blocks of code for multi-platform compatibility.
337337

338-
Copy `ImageFileInfo` from the desktop project and paste it into the `ImageFileInfo.cs` file. Make the following changes:
338+
Copy `ImageFileInfo` from the desktop project and paste it into the `ImageFileInfo.cs` file. Make the following changes:
339339

340340
- Rename the namespace to be `UnoSimplePhotos` instead of `SimplePhotos`:
341+
341342
```csharp
342343
// Found towards the top of the file
343344
namespace UnoSimplePhotos;
344345
```
346+
345347
- Change the parameter type of the `OnPropertyChanged` method to be nullable:
348+
346349
```csharp
347350
// string -> string?
348351
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
349352
...
350353
```
354+
351355
- Make the `PropertyChangedEventHandler` nullable:
356+
352357
```csharp
353358
// PropertyChangedEventHandler -> PropertyChangedEventHandler?
354359
public event PropertyChangedEventHandler? PropertyChanged;
@@ -572,7 +577,7 @@ private async void ShowImage(ListViewBase sender, ContainerContentChangingEventA
572577
}
573578
```
574579

575-
Again, preprocessor directives ensure that the `ContainerContentChangingEventArgs.Phase` property is only used where it is supported. We make use of the previously unused `GetImageSourceAsync()` method to load the image files into the `GridView` on platforms other than Windows. At this point, we will accommodate the changes made above by editing the `ImageFileInfo` class.
580+
Again, preprocessor directives ensure that the `ContainerContentChangingEventArgs.Phase` property is only used where it is supported. We make use of the previously unused `GetImageSourceAsync()` method to load the image files into the `GridView` on platforms other than Windows. At this point, we will accommodate the changes made above by editing the `ImageFileInfo` class.
576581

577582
### Creating a separate code path for other platforms
578583

@@ -626,6 +631,7 @@ To prevent getting the value of `ImageProperties` when it's null, we will need t
626631
```csharp
627632
public string ImageDimensions => $"{ImageProperties?.Width} x {ImageProperties?.Height}";
628633
```
634+
629635
- Change the `ImageTitle` property to use the null conditional operator:
630636

631637
```csharp
@@ -646,6 +652,7 @@ To prevent getting the value of `ImageProperties` when it's null, we will need t
646652
}
647653
}
648654
```
655+
649656
- Change `ImageRating` to not rely on `ImageProperties` by generating a random star rating for demonstration purposes:
650657

651658
```csharp
@@ -666,6 +673,7 @@ To prevent getting the value of `ImageProperties` when it's null, we will need t
666673
}
667674
}
668675
```
676+
669677
- Update the constructor that generates a random integer to no longer do this:
670678

671679
```csharp
@@ -834,7 +842,7 @@ The `MainPage.xaml` file should now look like this:
834842
mc:Ignorable="d"
835843
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
836844

837-
<Grid>
845+
<Grid>
838846
<Grid.Resources>
839847
<DataTemplate x:Key="ImageGridView_ItemTemplate"
840848
x:DataType="local:ImageFileInfo">
@@ -851,24 +859,24 @@ The `MainPage.xaml` file should now look like this:
851859
Stretch="Uniform" />
852860

853861
<StackPanel Orientation="Vertical"
854-
Grid.Row="1">
855-
<TextBlock Text="{x:Bind ImageTitle}"
856-
HorizontalAlignment="Center"
857-
Style="{StaticResource SubtitleTextBlockStyle}" />
858-
<StackPanel Orientation="Horizontal"
859-
HorizontalAlignment="Center">
860-
<TextBlock Text="{x:Bind ImageFileType}"
861-
HorizontalAlignment="Center"
862-
Style="{StaticResource CaptionTextBlockStyle}" />
863-
<win:TextBlock Text="{x:Bind ImageDimensions}"
862+
Grid.Row="1">
863+
<TextBlock Text="{x:Bind ImageTitle}"
864+
HorizontalAlignment="Center"
865+
Style="{StaticResource SubtitleTextBlockStyle}" />
866+
<StackPanel Orientation="Horizontal"
867+
HorizontalAlignment="Center">
868+
<TextBlock Text="{x:Bind ImageFileType}"
869+
HorizontalAlignment="Center"
870+
Style="{StaticResource CaptionTextBlockStyle}" />
871+
<win:TextBlock Text="{x:Bind ImageDimensions}"
864872
HorizontalAlignment="Center"
865873
Style="{StaticResource CaptionTextBlockStyle}"
866874
Margin="8,0,0,0" />
867-
</StackPanel>
875+
</StackPanel>
868876

869-
<RatingControl Value="{x:Bind ImageRating}"
870-
IsReadOnly="True" />
871-
</StackPanel>
877+
<RatingControl Value="{x:Bind ImageRating}"
878+
IsReadOnly="True" />
879+
</StackPanel>
872880
</Grid>
873881
</DataTemplate>
874882

@@ -902,29 +910,29 @@ Launch the `UnoSimplePhotos.Windows` target. Observe that this WinUI app is very
902910

903911
You can now build and run your app on any of the supported platforms. To do so, you can use the debug toolbar drop-down to select a target platform to deploy:
904912

905-
* To run the **WebAssembly** (Wasm) head:
906-
- Right-click on the `UnoSimplePhotos.Wasm` project, select **Set as startup project**
907-
- Press the `UnoSimplePhotos.Wasm` button to deploy the app
908-
- If desired, you can add and use the `UnoSimplePhotos.Server` project as an alternative
909-
* To debug for **iOS**:
910-
- Right-click on the `UnoSimplePhotos.Mobile` project, and select **Set as startup project**
911-
- In the debug toolbar drop-down, select an active iOS device or the simulator. You'll need to be paired with a Mac for this to work.
913+
- To run the **WebAssembly** (Wasm) head:
914+
- Right-click on the `UnoSimplePhotos.Wasm` project, select **Set as startup project**
915+
- Press the `UnoSimplePhotos.Wasm` button to deploy the app
916+
- If desired, you can add and use the `UnoSimplePhotos.Server` project as an alternative
917+
- To debug for **iOS**:
918+
- Right-click on the `UnoSimplePhotos.Mobile` project, and select **Set as startup project**
919+
- In the debug toolbar drop-down, select an active iOS device or the simulator. You'll need to be paired with a Mac for this to work.
912920

913921
:::image type="content" source="../images/uno/uno-mobile-debug.png" alt-text="Visual Studio dropdown to select a target framework to deploy":::
914922

915-
* To debug for **Mac Catalyst**:
916-
- Right-click on the `UnoSimplePhotos.Mobile` project, and select **Set as startup project**
917-
- In the debug toolbar drop-down, select a remote macOS device. You'll need to be paired with one for this to work.
918-
* To debug the **Android** platform:
919-
- Right-click on the `UnoSimplePhotos.Mobile` project, and select **Set as startup project**
920-
- In the debug toolbar drop-down, select either an active Android device or the emulator
921-
- Select an active device in the "Device" sub-menu
922-
* To debug on **Linux** with **Skia GTK**:
923-
- Right-click on the `UnoSimplePhotos.Skia.Gtk` project, and select **Set as startup project**
924-
- Press the `UnoSimplePhotos.Skia.Gtk` button to deploy the app
923+
- To debug for **Mac Catalyst**:
924+
- Right-click on the `UnoSimplePhotos.Mobile` project, and select **Set as startup project**
925+
- In the debug toolbar drop-down, select a remote macOS device. You'll need to be paired with one for this to work.
926+
- To debug the **Android** platform:
927+
- Right-click on the `UnoSimplePhotos.Mobile` project, and select **Set as startup project**
928+
- In the debug toolbar drop-down, select either an active Android device or the emulator
929+
- Select an active device in the "Device" sub-menu
930+
- To debug on **Linux** with **Skia GTK**:
931+
- Right-click on the `UnoSimplePhotos.Skia.Gtk` project, and select **Set as startup project**
932+
- Press the `UnoSimplePhotos.Skia.Gtk` button to deploy the app
925933

926934
## See also
927935

928936
- [Uno Platform documentation](https://platform.uno/docs/articles/intro.html)
929937
- [Update ListView and GridView items progressively](https://learn.microsoft.com/windows/uwp/debug-test-perf/optimize-gridview-and-listview#update-listview-and-gridview-items-progressively)
930-
- [Simple photo viewer tutorial](../get-started/simple-photo-viewer-winui3.md)
938+
- [Simple photo viewer tutorial](../get-started/simple-photo-viewer-winui3.md)

0 commit comments

Comments
 (0)