From e18202597ed75d2f9f261990e1cd2170b21e981d Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Wed, 27 Mar 2024 10:54:04 -0600 Subject: [PATCH] docs: Add docs for Style where no extension exists --- doc/Learn/Markup/Styles.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/Learn/Markup/Styles.md b/doc/Learn/Markup/Styles.md index 720489dc0d..0162d28d5e 100644 --- a/doc/Learn/Markup/Styles.md +++ b/doc/Learn/Markup/Styles.md @@ -10,6 +10,15 @@ new Style() .Setters(s => s.FontSize(14)) ``` +## Using Attached Properties + +By default the C# Markup Generators will provide friendly extension methods for properties on the given type for `Style`. This provides an API that is friendly and familiar to the XAML you might be used to as shown in the example above. Sometimes you may need to use Attached DependencyProperties for which there is no generated extension for `Style`, in these cases you can simply call the Add method and pass in both the DependencyProperty and the value: + +```cs +new Style() + .Setters(s => s.Add(HitchhikerGuide.AnswerProperty, 42)); +``` + ## Basing a Style on another Style Sometimes you may want to base a style on another style. This can be done one of two ways. The first is that you can provide the name/key of the style. It is important to remember that this has a limitation of only working for globally accessible styles through the Application and is best used for default styles.