You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hub/apps/develop/platform/xaml/attached-properties-overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,7 +117,7 @@ The dot in an attached property name is a key part of the identification pattern
117
117
- 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).
118
118
119
119
> [!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.
121
121
122
122
- 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).
Copy file name to clipboardExpand all lines: hub/apps/develop/platform/xaml/custom-attached-properties.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,14 +20,14 @@ An _attached property_ is a XAML concept. Attached properties are typically defi
20
20
21
21
## Prerequisites
22
22
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#.
24
24
25
25
## Scenarios for attached properties
26
26
27
27
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).
28
28
29
29
> [!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.
Copy file name to clipboardExpand all lines: hub/apps/develop/platform/xaml/custom-dependency-properties.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
---
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.
3
3
title: Custom dependency properties
4
4
ms.assetid: 5ADF7935-F2CF-4BB6-B1A5-F535C2ED8EF8
5
5
ms.date: 09/08/2025
6
6
ms.topic: article
7
-
keywords: windows 10, uwp
7
+
keywords: windows 10, winui
8
8
ms.localizationpriority: medium
9
9
dev_langs:
10
10
- csharp
@@ -14,11 +14,11 @@ dev_langs:
14
14
---
15
15
# Custom dependency properties
16
16
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.
18
18
19
19
## Prerequisites
20
20
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#.
22
22
23
23
## What is a dependency property?
24
24
@@ -38,7 +38,7 @@ If you implement a custom dependency property yourself and want it to be public
38
38
39
39
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.
40
40
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:
42
42
43
43
- Setting the property through a [**Style**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.Style)
44
44
- 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
431
431
432
432
### DependencyObject and threading
433
433
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).
435
435
436
436
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.
Copy file name to clipboardExpand all lines: hub/apps/develop/platform/xaml/dependency-properties-overview.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
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.
3
3
title: Dependency properties overview
4
4
ms.assetid: AD649E66-F71C-4DAA-9994-617C886FDA7E
5
5
ms.date: 02/08/2017
@@ -9,13 +9,13 @@ ms.localizationpriority: medium
9
9
---
10
10
# Dependency properties overview
11
11
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.
13
13
14
14
## What is a dependency property?
15
15
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.
17
17
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.
19
19
20
20
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:
21
21
@@ -24,7 +24,7 @@ The purpose of dependency properties is to provide a systemic way to compute the
24
24
- Multiple-use templating patterns such as resources and styles
25
25
- Values known through parent-child relationships with other elements in the object tree
26
26
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:
28
28
29
29
- Data binding
30
30
- Styles
@@ -88,7 +88,7 @@ The following is the definitive order that the property system uses when assigni
88
88
89
89
### Templated properties
90
90
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.
92
92
93
93
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.
94
94
@@ -188,7 +188,7 @@ You can deliberately set a property to the default value even after you have alr
188
188
189
189
## **DependencyObject** and threading
190
190
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.
192
192
193
193
> [!NOTE]
194
194
> 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