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.
0 commit comments