Skip to content

Commit 2724e4c

Browse files
niels9001jwmsft
andauthored
XAML scrub (#6446)
* xaml * More * Update link to Common theme resources Xaml file --------- Co-authored-by: Jim Walker <[email protected]>
1 parent 68aabf9 commit 2724e4c

12 files changed

Lines changed: 81 additions & 97 deletions

hub/apps/develop/platform/xaml/attached-properties-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ The dot in an attached property name is a key part of the identification pattern
117117
- To specify an attached property as part of a target path for an animation, enclose the attached property name in parentheses `()`—for example, `(Canvas.Left)`. For more info, see [Property-path syntax](property-path-syntax.md).
118118
119119
> [!WARNING]
120-
> An existing limitation of the Windows Runtime XAML implementation is that you cannot animate a custom attached property.
120+
> An existing limitation of the WinUI implementation is that you cannot animate a custom attached property.
121121
122122
- To specify an attached property as the target property for a resource reference from a resource file to **x:Uid**, use a special syntax that injects a code-style, fully qualified **using:** declaration inside square brackets ("\[\]"), to create a deliberate scope break. For example, assuming there exists an element `<TextBlock x:Uid="Title" />`, the resource key in the resource file that targets the **Canvas.Top** value on that instance is `Title.\[using:Microsoft.UI.Xaml.Controls\]Canvas.Top`. For more info on resource files and XAML, see [Localize strings in your UI](../../../windows-app-sdk/mrtcore/localize-strings.md).
123123

hub/apps/develop/platform/xaml/custom-attached-properties.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ An _attached property_ is a XAML concept. Attached properties are typically defi
2020

2121
## Prerequisites
2222

23-
We assume that you understand dependency properties from the perspective of a consumer of existing dependency properties, and that you have read the [Dependency properties overview](dependency-properties-overview.md). You should also have read [Attached properties overview](attached-properties-overview.md). To follow the examples in this topic, you should also understand XAML and know how to write a basic Windows Runtime app using C++, C#, or Visual Basic.
23+
We assume that you understand dependency properties from the perspective of a consumer of existing dependency properties, and that you have read the [Dependency properties overview](dependency-properties-overview.md). You should also have read [Attached properties overview](attached-properties-overview.md). To follow the examples in this topic, you should also understand XAML and know how to write a basic WinUI app using C++ or C#.
2424

2525
## Scenarios for attached properties
2626

2727
You might create an attached property when there is a reason to have a property-setting mechanism available for classes other than the defining class. The most common scenarios for this are layout and services support. Examples of existing layout properties are [**Canvas.ZIndex**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.canvas.zindex) and [**Canvas.Top**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.canvas.top). In a layout scenario, elements that exist as child elements to layout-controlling elements can express layout requirements to their parent elements individually, each setting a property value that the parent defines as an attached property. An example of the services-support scenario in the Windows Runtime API is set of the attached properties of [**ScrollViewer**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.Controls.ScrollViewer), such as [**ScrollViewer.IsZoomChainingEnabled**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.scrollviewer.iszoomchainingenabled).
2828

2929
> [!WARNING]
30-
> An existing limitation of the Windows Runtime XAML implementation is that you cannot animate your custom attached property.
30+
> An existing limitation of the WinUI app implementation is that you cannot animate your custom attached property.
3131
3232
## Registering a custom attached property
3333

hub/apps/develop/platform/xaml/custom-dependency-properties.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
description: Explains how to define and implement custom dependency properties for a Windows Runtime app using C++, C#, or Visual Basic.
2+
description: Explains how to define and implement custom dependency properties for a WinUI app using C++, C#, or Visual Basic.
33
title: Custom dependency properties
44
ms.assetid: 5ADF7935-F2CF-4BB6-B1A5-F535C2ED8EF8
55
ms.date: 09/08/2025
66
ms.topic: article
7-
keywords: windows 10, uwp
7+
keywords: windows 10, winui
88
ms.localizationpriority: medium
99
dev_langs:
1010
- csharp
@@ -14,11 +14,11 @@ dev_langs:
1414
---
1515
# Custom dependency properties
1616

17-
Here we explain how to define and implement your own dependency properties for a Windows Runtime app using C++, C#, or Visual Basic. We list reasons why app developers and component authors might want to create custom dependency properties. We describe the implementation steps for a custom dependency property, as well as some best practices that can improve performance, usability, or versatility of the dependency property.
17+
Here we explain how to define and implement your own dependency properties for a WinUI app using C++, C#, or Visual Basic. We list reasons why app developers and component authors might want to create custom dependency properties. We describe the implementation steps for a custom dependency property, as well as some best practices that can improve performance, usability, or versatility of the dependency property.
1818

1919
## Prerequisites
2020

21-
We assume that you have read the [Dependency properties overview](dependency-properties-overview.md) and that you understand dependency properties from the perspective of a consumer of existing dependency properties. To follow the examples in this topic, you should also understand XAML and know how to write a basic Windows Runtime app using C++, C#, or Visual Basic.
21+
We assume that you have read the [Dependency properties overview](dependency-properties-overview.md) and that you understand dependency properties from the perspective of a consumer of existing dependency properties. To follow the examples in this topic, you should also understand XAML and know how to write a basic WinUI app using C++ or C#.
2222

2323
## What is a dependency property?
2424

@@ -38,7 +38,7 @@ If you implement a custom dependency property yourself and want it to be public
3838

3939
Whenever you implement a public read/write property on a class, as long as your class derives from [**DependencyObject**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.DependencyObject), you have the option to make your property work as a dependency property. Sometimes the typical technique of backing your property with a private field is adequate. Defining your custom property as a dependency property is not always necessary or appropriate. The choice will depend on the scenarios that you intend your property to support.
4040

41-
You might consider implementing your property as a dependency property when you want it to support one or more of these features of the Windows Runtime or of Windows Runtime apps:
41+
You might consider implementing your property as a dependency property when you want it to support one or more of these features of the Windows Runtime or of WinUI apps:
4242

4343
- Setting the property through a [**Style**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.Style)
4444
- Acting as valid target property for data binding with [**{Binding}**](binding-markup-extension.md)
@@ -431,7 +431,7 @@ Keep the following considerations in mind as best practices when as you define y
431431

432432
### DependencyObject and threading
433433

434-
All [**DependencyObject**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.DependencyObject) instances must be created on the UI thread which is associated with the current [**Window**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.Window) that is shown by a Windows Runtime app. Although each **DependencyObject** must be created on the main UI thread, the objects can be accessed using a dispatcher reference from other threads, by calling [**Dispatcher**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.dependencyobject.dispatcher).
434+
All [**DependencyObject**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.DependencyObject) instances must be created on the UI thread which is associated with the current [**Window**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.Window) that is shown by a WinUI app. Although each **DependencyObject** must be created on the main UI thread, the objects can be accessed using a dispatcher reference from other threads, by calling [**Dispatcher**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.dependencyobject.dispatcher).
435435

436436
The threading aspects of [**DependencyObject**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.DependencyObject) are relevant because it generally means that only code that runs on the UI thread can change or even read the value of a dependency property. Threading issues can usually be avoided in typical UI code that makes correct use of **async** patterns and background worker threads. You typically only run into **DependencyObject**-related threading issues if you are defining your own **DependencyObject** types and you attempt to use them for data sources or other scenarios where a **DependencyObject** isn't necessarily appropriate.
437437

hub/apps/develop/platform/xaml/dependency-properties-overview.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: This topic explains the dependency property system that is available when you write a Windows Runtime app using C++, C#, or Visual Basic along with XAML definitions for UI.
2+
description: This topic explains the dependency property system that is available when you write a WinUI app using C++, C#, or Visual Basic along with XAML definitions for UI.
33
title: Dependency properties overview
44
ms.assetid: AD649E66-F71C-4DAA-9994-617C886FDA7E
55
ms.date: 02/08/2017
@@ -9,13 +9,13 @@ ms.localizationpriority: medium
99
---
1010
# Dependency properties overview
1111

12-
This topic explains the dependency property system that is available when you write a Windows Runtime app with XAML definitions for UI.
12+
This topic explains the dependency property system that is available when you write a WinUI app with XAML definitions for UI.
1313

1414
## What is a dependency property?
1515

16-
A dependency property is a specialized type of property. Specifically it's a property where the property's value is tracked and influenced by a dedicated property system that is part of the Windows Runtime.
16+
A dependency property is a specialized type of property. Specifically it's a property where the property's value is tracked and influenced by a dedicated property system that is part of the WinUI.
1717

18-
In order to support a dependency property, the object that defines the property must be a [**DependencyObject**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.dependencyobject) (in other words a class that has the **DependencyObject** base class somewhere in its inheritance). Many of the types you use for your UI definitions for a UWP app with XAML will be a **DependencyObject** subclass, and will support dependency properties. However, any type that comes from a Windows Runtime namespace that doesn't have "XAML" in its name won't support dependency properties; properties of such types are ordinary properties that won't have the property system's dependency behavior.
18+
In order to support a dependency property, the object that defines the property must be a [**DependencyObject**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.dependencyobject) (in other words a class that has the **DependencyObject** base class somewhere in its inheritance). Many of the types you use for your UI definitions for a WinUI app with XAML will be a **DependencyObject** subclass, and will support dependency properties. However, any type that comes from a Windows Runtime namespace that doesn't have "XAML" in its name won't support dependency properties; properties of such types are ordinary properties that won't have the property system's dependency behavior.
1919

2020
The purpose of dependency properties is to provide a systemic way to compute the value of a property based on other inputs (other properties, events and states that occur within your app while it runs). These other inputs might include:
2121

@@ -24,7 +24,7 @@ The purpose of dependency properties is to provide a systemic way to compute the
2424
- Multiple-use templating patterns such as resources and styles
2525
- Values known through parent-child relationships with other elements in the object tree
2626

27-
A dependency property represents or supports a specific feature of the programming model for defining a Windows Runtime app with XAML for UI. These features include:
27+
A dependency property represents or supports a specific feature of the programming model for defining a WinUI app with XAML for UI. These features include:
2828

2929
- Data binding
3030
- Styles
@@ -88,7 +88,7 @@ The following is the definitive order that the property system uses when assigni
8888

8989
### Templated properties
9090

91-
Templated properties as a precedence item do not apply to any property of an element that you declare directly in XAML page markup. The templated property concept exists only for objects that are created when the Windows Runtime applies a XAML template to a UI element and thus defines its visuals.
91+
Templated properties as a precedence item do not apply to any property of an element that you declare directly in XAML page markup. The templated property concept exists only for objects that are created when the WinUI applies a XAML template to a UI element and thus defines its visuals.
9292

9393
All the properties that are set from a control template have values of some kind. These values are almost like an extended set of default values for the control and are often associated with values you can reset later by setting the property values directly. Thus the template-set values must be distinguishable from a true local value, so that any new local value can overwrite it.
9494

@@ -188,7 +188,7 @@ You can deliberately set a property to the default value even after you have alr
188188

189189
## **DependencyObject** and threading
190190

191-
All [**DependencyObject**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.dependencyobject) instances must be created on the UI thread which is associated with the current [**Window**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.Window) that is shown by a Windows Runtime app. Although each **DependencyObject** must be created on the main UI thread, the objects can be accessed using a dispatcher reference from other threads, by accessing the [**DispatcherQueue**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.dependencyobject.dispatcherqueue) property. Then you can call methods such as [**TryEnqueue**](/windows/windows-app-sdk/api/winrt/microsoft.ui.dispatching.dispatcherqueue.tryenqueue) and execute your code within the rules of thread restrictions on the UI thread.
191+
All [**DependencyObject**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.dependencyobject) instances must be created on the UI thread which is associated with the current [**Window**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.Window) that is shown by a WinUI app. Although each **DependencyObject** must be created on the main UI thread, the objects can be accessed using a dispatcher reference from other threads, by accessing the [**DispatcherQueue**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.dependencyobject.dispatcherqueue) property. Then you can call methods such as [**TryEnqueue**](/windows/windows-app-sdk/api/winrt/microsoft.ui.dispatching.dispatcherqueue.tryenqueue) and execute your code within the rules of thread restrictions on the UI thread.
192192

193193
> [!NOTE]
194194
> For UWP apps, access the [**Dispatcher**](/uwp/api/windows.ui.xaml.dependencyobject.dispatcher) property. Then you can call methods such as [**RunAsync**](/uwp/api/windows.ui.core.coredispatcher.runasync) on the [**CoreDispatcher**](/uwp/api/Windows.UI.Core.CoreDispatcher) object, and execute your code within the rules of thread restrictions on the UI thread. For more info about differences between UWP and WinUI 3 for the Windows App SDK, see [Threading functionality migration](../../../windows-app-sdk/migrate-to-windows-app-sdk/guides/threading.md).

0 commit comments

Comments
 (0)