Skip to content

Commit

Permalink
docs: Adjust documentation based on App.xaml changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jan 31, 2023
1 parent bf06dd5 commit a6242c4
Show file tree
Hide file tree
Showing 30 changed files with 55 additions and 51 deletions.
Binary file modified doc/articles/Assets/solution-structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/articles/Assets/tutorial01/create-models-folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/articles/Uno-UI-Performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Here's what to look for:
```
- Resources
- Avoid using `x:Name` in `ResourceDictionary` as those force early instantiation of the resource
- Use [`Uno.XamlMerge.Task`](https://github.com/unoplatform/uno.xamlmerge.task) to merge all top-level App.xaml resource dictionaries
- Use [`Uno.XamlMerge.Task`](https://github.com/unoplatform/uno.xamlmerge.task) to merge all top-level `AppResources.xaml` or `App.xaml` resource dictionaries

## WebAssembly specifics
- Building your application in Release configuration is critical to get the best performance.
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/controls/ComboBox.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ On Uno you can change this behavior.

### Change the default value for all the `ComboBox` in you application

The default placement for all `ComboBox` instances can be changed by setting the feature flag in the startup of your app (app.xaml.cs) :
The default placement for all `ComboBox` instances can be changed by setting the feature flag in the startup of your app (`app.cs` or `app.xaml.cs`) :

```cs
Uno.UI.FeatureConfiguration.ComboBox.DefaultDropDownPreferredPlacement = DropDownPlacement.Below;
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/controls/TimePicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ If you wish to customize the overlay color, add the following to your top-level
Color="Pink" />
```

Since **iOS14** the native `TimePicker` changed the way it's presented. By default iOS14 devices will display this new style. You can still force the previous style (the one found in iOS13 or earlier) by adding the following at your `App.xaml.cs` class:
Since **iOS14** the native `TimePicker` changed the way it's presented. By default iOS14 devices will display this new style. You can still force the previous style (the one found in iOS13 or earlier) by adding the following at your `App.cs` or `App.xaml.cs` class:

```csharp
Uno.UI.FeatureConfiguration.TimePicker.UseLegacyStyle = true;
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/controls/map-control-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The current implementation uses the native UIKit Map for iOS and the Google Play

1. Ensure your app is targeting Uno 3.3 or later.
2. Install the [Uno.UI.Maps NuGet package](https://www.nuget.org/packages/Uno.UI.Maps/) in the Android and/or iOS head projects of your app.
3. Add the `MapResources` resource dictionary to `Application.Resources` in your `App.xaml` file:
3. Add the `MapResources` resource dictionary to `Application.Resources` in your `AppResources.xaml` or `App.xaml` file:
```xml
<Application.Resources>
<MapResources xmlns="using:Uno.UI.Maps"/>
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/features/fluent-styles.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Uno Platform 3.0 and above supports control styles conforming to the [Fluent des

## Upgrading existing Uno apps to use Fluent styles

Overall, the Uno Platform uses the same mechanism as WinUI to enable Fluent styles. After installing the `Uno.UI` Nuget version 3.0 or above, Fluent styles are enabled by specifying the `XamlControlsResources` within the application's resources (inside `App.xaml`).
Overall, the Uno Platform uses the same mechanism as WinUI to enable Fluent styles. After installing the `Uno.UI` Nuget version 3.0 or above, Fluent styles are enabled by specifying the `XamlControlsResources` within the application's resources (inside `AppResources.xaml` or `App.xaml`).

For the UWP head, an additional WinUI 2 Nuget package reference must be added. This is following the same process as UWP because, for the UWP head, the Uno Platform is not used.

The step-by-step process to enable Fluent design styles within an existing Uno Platform solution is as follows:

1. In all platform head projects except UWP update the `Uno.UI` NuGet packages to 3.0 or above.
1. In only the `UWP` head project of your solution, if you have one, install the [WinUI 2 NuGet package](https://www.nuget.org/packages/Microsoft.UI.Xaml). This step is the same as required for WinUI 2 UWP apps.
1. Within the shared project used by all platform heads, add the `XamlControlsResources` resource dictionary to your application resources inside `App.xaml`. This step is the same as required for WinUI 2 UWP apps.
1. Within the shared project used by all platform heads, add the `XamlControlsResources` resource dictionary to your application resources inside `AppResources.xaml` or `App.xaml`. This step is the same as required for WinUI 2 UWP apps.
```xml
<Application>
<Application.Resources>
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/features/native-frame-nav.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ On Android and iOS, there is the option to enable native frame navigation. Enabl
- `Windows.UI.Xaml.Controls.CommandBar`
- `Windows.UI.Xaml.Controls.AppBarButton`

This feature can be enabled by calling the method below, typically in the constructor of your `App` class in `App.xaml.cs`:
This feature can be enabled by calling the method below, typically in the constructor of your `App` class in `App.cs` or `App.xaml.cs`:
```cs
#if __IOS__ || __ANDROID__
Uno.UI.FeatureConfiguration.Style.ConfigureNativeFrameNavigation();
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/features/protocol-activation.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Works according to Windows docs, see [Microsoft Docs](https://docs.microsoft.com

## Handling protocol activation

Custom URI activation can be handled by overriding the `OnActivated` method in `App.xaml.cs`:
Custom URI activation can be handled by overriding the `OnActivated` method in `App.cs` or `App.xaml.cs`:

```
protected override void OnActivated(IActivatedEventArgs e)
Expand Down Expand Up @@ -135,4 +135,4 @@ private Frame GetOrCreateRootFrame(IActivatedEventArgs eventArgs)

return rootFrame;
}
```
```
4 changes: 2 additions & 2 deletions doc/articles/features/resources-trimming.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ As of Uno 3.9, XAML Resources Trimming is only available for WebAssembly project

## Using XAML Resources trimming for applications

In order for an application to enable resources trimming, the following needs to be added in the project file:
In order for an application to enable resources trimming, the following needs to be added all projects of your solution which reference the Uno.WinUI (or Uno.UI) package, as well as the WebAssembly head project:

```xml
<PropertyGroup>
<UnoXamlResourcesTrimming>true</UnoXamlResourcesTrimming>
</PropertyGroup>
```

## Enabling XAML Resources trimming for libraries
## Enabling XAML Resources trimming for libraries and NuGet Packages
For libraries to be eligible for resources trimming, the `UnoXamlResourcesTrimming` tag must also be added.

## Troubleshooting
Expand Down
6 changes: 3 additions & 3 deletions doc/articles/features/uno-material.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ For complete instructions on using Uno Material in your projects, check out this
> Certain controls require [additional setup steps](uno-material-controls-extra-setup.md).

## Migrating From Previous Resource Initialization Method
Prior to the `1.0` release, the initialization of Material resources was required to be done through code-behind within the `App.xaml.cs` file. Resource initialization has now been moved to XAML-only. Follow the steps below to migrate from the old method of initialization to the new one:
Prior to the `1.0` release, the initialization of Material resources was required to be done through code-behind within the `App.cs` or `App.xaml.cs` file. Resource initialization has now been moved to XAML-only. Follow the steps below to migrate from the old method of initialization to the new one:

1. Remove the following code from `App.xaml.cs`
1. Remove the following code from `App.cs` or `App.xaml.cs`
```diff
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Expand All @@ -49,7 +49,7 @@ Prior to the `1.0` release, the initialization of Material resources was require
}

```
1. Add `MaterialColors` and `MaterialResources` to `App.xaml`:
1. Add `MaterialColors` and `MaterialResources` to `AppResources.xaml` or `App.xaml`:
```diff
<Application.Resources>
<ResourceDictionary>
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/features/using-linux-framebuffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dotnet publish -c Release -r linux-x64 --self-contained true
```

> [!NOTE]
> When using the `Release` configuration, logging is disabled for performance considerations. You can restore logging in the App.xaml.cs file.
> When using the `Release` configuration, logging is disabled for performance considerations. You can restore logging in the `App.xaml.cs` file.
Documentation on other hardware targets are [available here](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md).

Expand Down
6 changes: 4 additions & 2 deletions doc/articles/features/windows-storage-pickers.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ WinRT.Interop.InitializeWithWindow.Initialize(picker, hwnd);
await picker.PickSingleFileAsync();
```

To get the `Window` instance in single-window apps, it is easiest to create an `internal static MainWindow` property in the `App.xaml.cs` file, initialize it in `OnLaunched`, and then use it for this purpose:
To get the `Window` instance in single-window apps, it is easiest to create an `internal static MainWindow` property in the `App.cs` or `App.xaml.cs` file, initialize it in `OnLaunched`, and then use it for this purpose:

```csharp
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow);
Expand Down Expand Up @@ -355,16 +355,18 @@ namespace Custom.Pickers
#endif
```

When done, register this extension in `App.xaml.cs`:
When done, register this extension in `App.cs` or `App.xaml.cs`:

```csharp
public App()
{
...
#if __IOS__
ApiExtensibility.Register(
typeof(Uno.Extensions.Storage.Pickers.IFileSavePickerExtension),
picker => new CustomFileSavePickerExtension(picker));
#endif
...
}
```

Expand Down
6 changes: 3 additions & 3 deletions doc/articles/features/working-with-accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Instead of trying to replicate UWP's behavior on iOS (which *might* be doable us
Here's how to enable it:

```csharp
// App's constructor (App.xaml.cs)
// App's constructor (`App.cs` or `App.xaml.cs`)
#if __IOS__ || __ANDROID__ || __MACOS__ || __WASM__
FeatureConfiguration.AutomationPeer.UseSimpleAccessibility = true;
#endif
Expand All @@ -46,8 +46,8 @@ You have the option to disable accessibility text scaling of iOS and Android dev
Here's how to disable it

```csharp
// App's constructor (App.xaml.cs)
Uno.UI.FeatureConfiguration.Font.IgnoreTextScaleFactor= true;
// App's constructor (`App.cs` or `App.xaml.cs`)
Uno.UI.FeatureConfiguration.Font.IgnoreTextScaleFactor = true;
```

## AutomationId
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/features/working-with-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Because the `custom` qualifier doesn't have any special meaning on UWP, we have

On iOS and Android, Uno.UI's `RetargetAssets` task automatically interprets these values and excludes unsupported platforms.

On UWP, you must add the following code to your `App.xaml.cs` constructor:
On UWP, you must add the following code to your `App.cs` or `App.xaml.cs` constructor:

```csharp
#if WINDOWS_UWP
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/features/working-with-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Uno Platform supports `Light`, `Dark` and `HighContrast` themes similarly to UWP.

As in UWP, the default theme is `Dark`, but in the case of Uno we use `Light` for all supported systems, as that is the default on all except Windows. However, if you don't specify a theme in the constructor of `App` and don't specify it in `App.xaml` either, it will be determined by the current system theme on iOS, Android and to current system/browser theme (depending on browser implementation) on WASM.
As in UWP, the default theme is `Dark`, but in the case of Uno we use `Light` for all supported systems, as that is the default on all except Windows. However, if you don't specify a theme in the constructor of `App` and don't specify it in `AppResources.xaml` or `App.xaml` either, it will be determined by the current system theme on iOS, Android and to current system/browser theme (depending on browser implementation) on WASM.

To set `HighContrast` theme or a custom theme, you can use the `Uno.UI.ApplicationHelper` class:

Expand All @@ -16,7 +16,7 @@ Setting `Application.Current.RequestedTheme` outside of `App` constructor is not

## Reacting to OS theme changes

If you don't specify the theme in `App` constructor and `App.xaml`, your app will automatically adapt to OS theme changes at runtime. However, on Android, you need to make sure to add `ConfigChanges.UiMode` to the `MainActivity` `[Application]` attribute, for example:
If you don't specify the theme in `App` constructor and `AppResources.xaml` or `App.xaml`, your app will automatically adapt to OS theme changes at runtime. However, on Android, you need to make sure to add `ConfigChanges.UiMode` to the `MainActivity` `[Application]` attribute, for example:

``` c#
[Activity(
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/guides/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This guide will walk you through the necessary steps to localize an Uno Platform
Now, if you change the language of the targeted PC or the mobile device AND restart the app, that text should also change accordingly.

You can also set the starting culture to see the result, without having to modify the system language:
- `App.xaml.cs`:
- `App.cs` or `App.xaml.cs`:
```cs
public App()
{
Expand Down
2 changes: 1 addition & 1 deletion doc/articles/guides/native-frame-nav-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The complete sample code can be found here: [NativeFrameNav](https://github.com/
private void NavigateBack(object sender, RoutedEventArgs e) => Frame.GoBack(); // in both pages
```

6. Enable native frame navigation in `App.xaml.cs`:
6. Enable native frame navigation in `App.cs` or `App.xaml.cs`:
```cs
public App()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ There are a few steps to adding WinUI 2.5 to the Uno project:
> [!NOTE]
> The [Uno.UI](https://www.nuget.org/packages/Uno.UI) NuGet package already includes the WinUI 2.x bits so there are no changes for the WASM head.
1. To add the WinUI resources to the app, open the **App.xaml** file and add the following:
1. To add the WinUI resources to the app, open the `AppResources.xaml` or `App.xaml` file and add the following:
```xml
<Application.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Earlier application platforms had a simple lifecycle - once launched, they conti
> * [App Lifecycle](https://docs.microsoft.com/windows/uwp/launch-resume/app-lifecycle)
> * [Application Class](https://docs.microsoft.com/uwp/api/windows.ui.xaml.application?view=winrt-19041)
The Uno template generates a basic **App.xaml.cs** file that satisfies the minimum needs for app startup and suspension, and then configures the app to use a **Frame** control as the equivalent of the the Silverlight RootVisual, and then navigates to the **MainPage**, which displays "Hello, World!".
The Uno template generates a basic `App.cs` and `App.xaml.cs` file that satisfies the minimum needs for app startup and suspension, and then configures the app to use a **Frame** control as the equivalent of the the Silverlight RootVisual, and then navigates to the **MainPage**, which displays "Hello, World!".

Briefly reviewing the **App.xaml.cs** will reveal the following structure:
Briefly reviewing the `App.cs` and `App.xaml.cs` files will reveal the following structure:

* **Constructor** - as well as initializing the application component, the app logging configuration method **ConfigureFilters** is called, and a subscription to the **Suspending** event is added.
* **OnLaunched** - this method is called if the application is launched by the user - other methods (not implemented in this template) are called for other scenarios (see resources above). The current window is retrieved and the content is checked to see if a **Frame** is already instantiated (see note below). If not, a new frame is configured and set as the window content. The code then checks to see if the app has been prelaunched (see note below) - if not, and the root frame isn't already showing content, it is navigated to the **MainPage**. Finally the window is activated, which brings it to the foreground and applying input focus.
Expand All @@ -62,7 +62,7 @@ In order to better align with the behavior of the Silverlight version of the app

1. Return to the **TimeEntryUno** solution.

1. In the **[MyApp]** project, open the **App.xaml.cs** file
1. In the **[MyApp]** project, open the **App.cs** file

1. Locate the **OnLaunched** method and replace it with the following code:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ The next steps will show how migrate the Silverlight styles to work in the Uno a

1. Right-click the new **Resources** folder, select **Add &gt; New Item**, select **Resource Dictionary** and name it **Styles.xaml**.

To ensure the resource dictionary is loaded, it must be added to **App.xaml**.
To ensure the resource dictionary is loaded, it must be added to **AppResources.xaml**.

1. Open **App.xaml** and the reference to the **Styles.xaml** as shown below:
1. Open **AppResources.xaml** and the reference to the **Styles.xaml** as shown below:

```xml
<Application.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In the Silverlight project, the application string resources are found within th

![String Resource Home Navigation Page Title](assets/StringResource-HomeNav.png)

The **ResourceWrapper** helper is instantiated in the application resources defined in **App.xaml** as:
The **ResourceWrapper** helper is instantiated in the application resources defined in **AppResources.xaml** as:

```xml
<ResourceDictionary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The next task will discuss an approach to initializing the service.

## TokenService initialization

As the **TokenService** utilizes asynchronous initialization, there is an advantage to starting the initialization process as early as feasible in the application lifecycle. An example would be adding it to the **App.xaml.cs OnLaunched** method, as shown below:
As the **TokenService** utilizes asynchronous initialization, there is an advantage to starting the initialization process as early as feasible in the application lifecycle. An example would be adding it to the `App.cs` `OnLaunched` method, as shown below:

```csharp
protected override void OnLaunched(LaunchActivatedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions doc/articles/guides/status-bar-theme-color.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The complete sample code can be found here: [StatusBarThemeColor](https://github
public CommandBar GetCommandBar() => MyCommandBar;
```

5. In `App.xaml.cs`, enable the native frame navigation to use the native style for `CommandBar`, instead of the UWP style. Make sure that the `#if ... #endif` block is before `this.InitializeComponent()`:
5. In `App.cs`, enable the native frame navigation to use the native style for `CommandBar`, instead of the UWP style. Make sure that the `#if ... #endif` block is before `this.InitializeComponent()`:
```cs
public App()
{
Expand All @@ -66,7 +66,7 @@ The complete sample code can be found here: [StatusBarThemeColor](https://github
}
```

6. Subscribe to the `UISettings.ColorValuesChanged` event from `App.xaml.cs`:
6. Subscribe to the `UISettings.ColorValuesChanged` event from `App.cs`:
> Note that the instance of `UISettings` is kept to prevent it from being disposed when going out of scope, which would otherwise dispose the event subscription.
```cs
public sealed partial class App : Application
Expand Down
Loading

0 comments on commit a6242c4

Please sign in to comment.