Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hub/apps/develop/composition/composition-effects.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ new Microsoft.Graphics.Canvas.Effects.ArithmeticCompositeEffect
Source1Amount = 0.5f,
Source2Amount = 0.5f,
Offset = 0
}
};
```

The example above describes an arithmetic composite effect which has two inputs. The second input has a saturation effect with a .5 saturation property.
Expand Down
2 changes: 1 addition & 1 deletion hub/apps/develop/composition/pointer-input-animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Let's take a look at an example where we leverage the Hover position of a Mouse
The image is a UIElement, so let's first get a reference to the PointerPositionPropertySet

```csharp
_pointerPositionPropSet = ElementCompositionPreview.GetPointerPositionPropertySet(UIElement element);
_pointerPositionPropSet = ElementCompositionPreview.GetPointerPositionPropertySet(element);
```

In this sample, you have two Expressions at play:
Expand Down
4 changes: 2 additions & 2 deletions hub/apps/develop/data/store-and-retrieve-app-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async void WriteTimestamp()
new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");

StorageFile sampleFile = await temporaryFolder.CreateFileAsync("dataFile.txt",
CreateCollisionOption.ReplaceExisting);
CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTimeOffset.Now));
}
```
Expand Down Expand Up @@ -271,7 +271,7 @@ localSettings.DeleteContainer("exampleContainer");
## Versioning your app data


You can optionally version the app data for your app. This would enable you to create a future version of your app that changes the format of its app data without causing compatibility problems with the previous version of your app. The app checks the version of the app data in the data store, and if the version is less than the version the app expects, the app should update the app data to the new format and update the version. For more info, see the[**Application.Version**](/uwp/api/windows.storage.applicationdata.version) property and the [**ApplicationData.SetVersionAsync**](/uwp/api/windows.storage.applicationdata.setversionasync) method.
You can optionally version the app data for your app. This would enable you to create a future version of your app that changes the format of its app data without causing compatibility problems with the previous version of your app. The app checks the version of the app data in the data store, and if the version is less than the version the app expects, the app should update the app data to the new format and update the version. For more info, see the [**ApplicationData.Version**](/uwp/api/windows.storage.applicationdata.version) property and the [**ApplicationData.SetVersionAsync**](/uwp/api/windows.storage.applicationdata.setversionasync) method.

## Related articles

Expand Down
6 changes: 3 additions & 3 deletions hub/apps/develop/dispatcherqueue.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ms.localizationpriority: high
* It provides a means to register a delegate that's called when a timeout expires.
* It provides events that let components know when a message loop is exiting, and optionally defer that shutdown until outstanding work completes. That ensures components that use the **DispatcherQueue**, but don't own the message loop, may do cleanup on-thread as the loop exits.
* The **DispatcherQueue** is a thread singleton (there can be at most one of them running on any given thread). By default, a thread has no **DispatcherQueue**.
* A thread owner may create a [DispatcherQueueController](/windows/windows-app-sdk/api/winrt/microsoft.ui.dispatching.dispatcherqueuecontroller) to initialize the **DispatcherQueue** for the thread. At that point, any code can access the thread's **DispatcherQueue**; but only the **DispatcherQueueController**'s owner has access to the [DispatcherQueueController.ShutdownQueue](/windows/windows-app-sdk/api/winrt/microsoft.ui.dispatching.dispatcherqueuecontroller.shutdownqueue) method, which drains the **DispatcherQueue**, and raises **ShutdownStarted** and **ShutdownCompleted** events.
* A thread owner may create a [DispatcherQueueController](/windows/windows-app-sdk/api/winrt/microsoft.ui.dispatching.dispatcherqueuecontroller) to initialize the **DispatcherQueue** for the thread. At that point, any code can access the thread's **DispatcherQueue**; but only the **DispatcherQueueController**'s owner has access to the [DispatcherQueueController.ShutdownQueue](/windows/windows-app-sdk/api/winrt/microsoft.ui.dispatching.dispatcherqueuecontroller.shutdownqueue) method, which drains the **DispatcherQueue**, and raises **ShutdownStarting** and **ShutdownCompleted** events.
* An outermost message loop owner must create a **DispatcherQueue** instance. Only the code in charge of running a thread's outermost message loop knows when dispatch is complete, which is the appropriate time to shut down the **DispatcherQueue**. That means that components that rely on **DispatcherQueue** mustn't create the **DispatcherQueue** unless they own the thread's message loop.

## Run-down
Expand Down Expand Up @@ -55,7 +55,7 @@ void RunCustomMessageLoop()
{
if (!ContentPreTranslateMessage(&msg))
{
TranslateMesasge(&msg);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ void Main()
// Create a Windows App SDK DispatcherQueue.
auto dispatcherQueueController{winrt::DispatcherQueueController::CreateOnCurrentThread()};

var appWindow = AppWindow.Create(nullptr, 0, dispatcherQueueController.DispatcherQueue());
auto appWindow = AppWindow::Create(nullptr, 0, dispatcherQueueController.DispatcherQueue());

// Since we associated the DispatcherQueue above with the AppWindow, we're able to retrieve it
// as a property. If we were to not associate a dispatcher, this property would be null.
Expand Down
4 changes: 2 additions & 2 deletions hub/apps/develop/input/handle-pointer-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Receive, process, and manage input data from pointing devices (such as touch, mo

## Important APIs
- [Windows.Devices.Input](/uwp/api/Windows.Devices.Input)
- [Windows.UI.Input](/uwp/api/Windows.UI.Core)
- [Windows.UI.Xaml.Input](/uwp/api/Windows.UI.Input)
- [Windows.UI.Input](/uwp/api/Windows.UI.Input)
- [Windows.UI.Xaml.Input](/uwp/api/Windows.UI.Xaml.Input)

## Pointers
Most interaction experiences typically involve the user identifying the object they want to interact with by pointing at it through input devices such as touch, mouse, pen/stylus, and touchpad. Because the raw Human Interface Device (HID) data provided by these input devices includes many common properties, the data is promoted and consolidated into a unified input stack and exposed as device-agnostic pointer data. Your Windows applications can then consume this data without worrying about the input device being used.
Expand Down
2 changes: 1 addition & 1 deletion hub/apps/develop/input/identify-input-devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ms.localizationpriority: medium

Identify the input devices connected to a Windows app device and identify their capabilities and attributes.

> **Important APIs**: [**Windows.Devices.Input**](/uwp/api/Windows.Devices.Input), [**Windows.UI.Input**](/uwp/api/Windows.UI.Core), [**Windows.UI.Xaml.Input**](/uwp/api/Windows.UI.Input)
> **Important APIs**: [**Windows.Devices.Input**](/uwp/api/Windows.Devices.Input), [**Windows.UI.Input**](/uwp/api/Windows.UI.Input), [**Windows.UI.Xaml.Input**](/uwp/api/Windows.UI.Xaml.Input)

## Retrieve mouse properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Create a new instance of **MediaSource** by calling one of the factory methods e

After creating a **MediaSource** you can play it with a [**MediaPlayer**](/uwp/api/Windows.Media.Playback.MediaPlayer) by setting the [**Source**](/uwp/api/windows.media.playback.mediaplayer.source) property. You can assign a **MediaPlayer** to a [**MediaPlayerElement**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.mediaplayerelement) by calling [**SetMediaPlayer**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.mediaplayerelement.setmediaplayer) in order to render the media player content in a XAML page. This is the preferred method over using **MediaElement**. For more information on using **MediaPlayer**, see [**Play audio and video with MediaPlayer**](play-audio-and-video-with-mediaplayer.md).

The following example shows how to play back a user-selected media file in a **MediaPlayer** using **MediaSource**. To allow the user to pick a media file to play, use a [**FileOpenPicker**](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker). Create an instance of [**StorageFile**](/uwp/api/Windows.Storage.StorageFile) from the path returned from the picker's [**PickSingleFileAsync**](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker.picksinglefileasync) method and initialize a new **MediaSource** object by calling [**MediaSource.CreateFromStorageFile**](/uwp/api/windows.media.core.mediasource.createfromstoragefile). Finally, set the media source as the playback source for the **MediaPlayer** by setting the [**SetPlaybackSource**](/uwp/api/windows.media.playback.mediaplayer.source) property.
The following example shows how to play back a user-selected media file in a **MediaPlayer** using **MediaSource**. To allow the user to pick a media file to play, use a [**FileOpenPicker**](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker). Create an instance of [**StorageFile**](/uwp/api/Windows.Storage.StorageFile) from the path returned from the picker's [**PickSingleFileAsync**](/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers.fileopenpicker.picksinglefileasync) method and initialize a new **MediaSource** object by calling [**MediaSource.CreateFromStorageFile**](/uwp/api/windows.media.core.mediasource.createfromstoragefile). Finally, set the media source as the playback source for the **MediaPlayer** by setting the [**Source**](/uwp/api/windows.media.playback.mediaplayer.source) property.

:::code language="xml" source="~/../snippets-windows/winappsdk/audio-video-camera/media-source-winui/cs/MediaSourceWinUI/MainWindow.xaml" id="SnippetMediaPlayerElement":::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ When a user clicks on an app notification or a button within a notification, you
1. **Launch with UI** — The user clicks the notification body and your app should launch or come to the foreground, displaying relevant content.
2. **Background action** — The user clicks a button in the notification that triggers an action (such as sending a reply) without showing any app UI.

To support both scenarios, your app's activation flow should create the main window in `OnLaunched` but *not* activate it immediately. Instead, register the [AppNotificationManager.NotificationInvoked](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotificationmanager.notificationinvoked) event, call [AppNotificationManager.Register](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotificationmanager.register), and then check [AppInstance.GetActivatedEventArgs](/windows/windows-app-sdk/api/winrt/microsoft.windows.applifecycle.appinstance.getactivatedeventargs) to determine whether the app was launched from a notification or from a normal launch. If the launch was triggered by a notification, your code can inspect the notification arguments and decide whether to show the window or handle the action silently and exit.
To support both scenarios, your app's activation flow should create the main window in `OnLaunched` but *not* activate it immediately. Instead, register the [AppNotificationManager.NotificationInvoked](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotificationmanager.notificationinvoked) event, call [AppNotificationManager.Register](/windows/windows-app-sdk/api/winrt/microsoft.windows.appnotifications.appnotificationmanager.register), and then check [AppInstance.GetActivatedEventArgs](/windows/windows-app-sdk/api/winrt/microsoft.windows.applifecycle.appinstance.getactivatedeventargs) to determine whether this is a normal launch or a COM activation path that should wait for `NotificationInvoked`. Your code can then decide whether to show the window or handle the action silently and exit.

The `NotificationInvoked` event handles clicks that occur while the app is already running. When the app is not running, Windows launches the app via COM activation and the activation kind is reported as `Launch`, not `AppNotification`. The notification arguments are then delivered through the `NotificationInvoked` event.

Expand Down
4 changes: 2 additions & 2 deletions hub/apps/develop/testing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ namespace WinUITest1
11. Open the UserControl1.xaml.cs code-behind file. For this example, we add a new public method called `GetSeven` that simply returns an integer.

```csharp
namespace WinUICLassLibrary1
namespace WinUIClassLibrary1
{
public sealed partial class UserControll : UserControl
public sealed partial class UserControl1 : UserControl
{
public UserControl1()
{
Expand Down
14 changes: 8 additions & 6 deletions hub/apps/develop/win2d/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ Before you continue, first ensure that the project's Architecture option is set
2. At the top of the C# file are various namespace definitions. Add the following namespaces:

```csharp
using Windows.UI;
using System.Numerics;
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.UI;
```

3. Next, you should see the following blank event handler which was inserted by AutoComplete:
Expand Down Expand Up @@ -101,7 +103,7 @@ For more information, see [Avoiding memory leaks](./avoiding-memory-leaks.md).
3. Add a handler for the `Unloaded` event. Your XAML should look like this:

```XAML
<Page
<Window
...
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"
Expand Down Expand Up @@ -237,21 +239,21 @@ args.DrawingSession.DrawImage(blur);

**CanvasControl** is best suited for mostly static graphics content - it only raises the `Draw` event when your content needs to be updated or redrawn. If you have continually changing content then you should consider using `CanvasAnimatedControl` instead. The two controls operate very similarly, except `CanvasAnimatedControl` raises the `Draw` event on a periodic basis; by default it is called 60 times per second.

2. To switch to `CanvasAnimatedControl`, go to `MainPage.xaml`, delete the **CanvasControl** line, and replace it with the following XAML:
2. To switch to `CanvasAnimatedControl`, go to `MainWindow.xaml`, delete the **CanvasControl** line, and replace it with the following XAML:

```XAML
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<canvas:CanvasAnimatedControl x:Name="canvas" Draw="canvas_DrawAnimated" CreateResources="canvas_CreateResources"/>
</Grid>
```

Just like with **CanvasControl**, let AutoComplete create the `Draw` event handler for you. By default, Visual Studio will name this handler `canvas_Draw_1` because `canvas_Draw` already exists; here, we've renamed the method `canvas_AnimatedDraw` to make it clear that this is a different event.
Just like with **CanvasControl**, let AutoComplete create the `Draw` event handler for you. By default, Visual Studio will name this handler `canvas_Draw_1` because `canvas_Draw` already exists; here, we've renamed the method `canvas_DrawAnimated` to make it clear that this is a different event.

In addition, you are also handling a new event, [CreateResources](https://microsoft.github.io/Win2D/WinUI2/html/E_Microsoft_Graphics_Canvas_UI_Xaml_CanvasAnimatedControl_CreateResources.htm). Once again, let AutoComplete create the handler.

Now that your app will be redrawing at 60 frames per second, it is more efficient to create your Win2D visual resources once and reuse them with every frame. It is inefficient to create a `CanvasCommandList` and draw 300 elements into it 60 times per second when the content remains static. `CreateResources` is an event that is fired only when Win2D determines you need to recreate your visual resources, such as when the page is loaded.

3. Switch back to `MainPage.xaml.cs`. Find your `canvas_Draw` method which should look like this:
3. Switch back to `MainWindow.xaml.cs`. Find your `canvas_Draw` method which should look like this:

```csharp
private void canvas_Draw(
Expand Down Expand Up @@ -289,7 +291,7 @@ private void canvas_CreateResources(
{}
```

Paste (CTRL+V) your previously cut code into this method. Next, move the declaration of `GaussianBlurEffect` outside the method body so the variable becomes a member of the MainPage class. Your code should now look like the following:
Paste (CTRL+V) your previously cut code into this method. Next, move the declaration of `GaussianBlurEffect` outside the method body so the variable becomes a member of the MainWindow class. Your code should now look like the following:

```csharp
GaussianBlurEffect blur;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ There are differences in the names of namespaces and classes (including UI contr
| (**Windows.UI.Core**) [**CoreWindow.SizeChanged**](/uwp/api/windows.ui.core.corewindow.sizechanged) event | (**Microsoft.UI.Windowing**) [**AppWindowChangedEventArgs.DidSizeChange**](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowchangedeventargs.didsizechange) method |
| (**Windows.UI.Core**) [**SystemNavigationManager**](/uwp/api/Windows.UI.Core.SystemNavigationManager) class (global back button) | Not supported. Implement a back button within your own UI. See [A Windows App SDK migration of the UWP PhotoLab sample app (C#)](case-study-1.md). |
| (**Windows.UI.Core**) [**WindowSizeChangedEventArgs**](/uwp/api/windows.ui.core.windowsizechangedeventargs) class | (**Microsoft.UI.Xaml**) [**WindowSizeChangedEventArgs**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.windowsizechangedeventargs) class; for example, in a handler for (**Microsoft.UI.Xaml**) [**Window.SizeChanged**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window.sizechanged). |
| (**Windows.UI.Popups**) [**MessageDialog**](/uwp/api/Windows.Storage.Pickers.FileOpenPicker) class | Supported, but you must use the [**IInitializeWithWindow**](/windows/win32/api/shobjidl_core/nn-shobjidl_core-iinitializewithwindow) interface. See [MessageDialog, and Pickers](guides/winui3.md#messagedialog-and-pickers). |
| (**Windows.UI.Popups**) [**MessageDialog**](/uwp/api/windows.ui.popups.messagedialog) class | Supported, but you must use the [**IInitializeWithWindow**](/windows/win32/api/shobjidl_core/nn-shobjidl_core-iinitializewithwindow) interface. See [MessageDialog, and Pickers](guides/winui3.md#messagedialog-and-pickers). |
| (**Windows.UI.Text.Core**) [**CoreTextServicesManager**](/uwp/api/windows.ui.text.core.coretextservicesmanager) class | Supported only on Windows 11. |
| (**Windows.UI.ViewManagement**) [**AccessibilitySettings.HighContrastChanged**](/uwp/api/windows.ui.viewmanagement.accessibilitysettings.highcontrastchanged) event | (**Microsoft.UI.System**) [**ThemeSettings.Changed**](/windows/windows-app-sdk/api/winrt/microsoft.ui.system.themesettings.changed) event |
| (**Windows.UI.ViewManagement**) [**ApplicationView**](/uwp/api/windows.ui.viewmanagement.applicationview) class | (**Microsoft.UI.Windowing**) [**AppWindow**](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindow) class |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void HandleNotification(AppNotificationActivatedEventArgs args)

dispatcherQueue.TryEnqueue(async delegate
{
if (args.Argument.Contains("action"))
if (args.Arguments.ContainsKey("action"))
{
switch (args.Arguments["action"])
{
Expand Down
Loading