diff --git a/doc/articles/features/windows-ui-markup-extensions.md b/doc/articles/features/windows-ui-markup-extensions.md index da1e7d762e9c..6fb35ee6017a 100644 --- a/doc/articles/features/windows-ui-markup-extensions.md +++ b/doc/articles/features/windows-ui-markup-extensions.md @@ -89,17 +89,15 @@ Using the following XAML: ```csharp public class DynamicBindExtension : MarkupExtension { - public DynamicBindExtension(string propertyName) - { - _propertyName = propertyName; - } - string _propertyName; + public DynamicBindExtension() { } + + public string Name { get; set; } = ""; - public override object ProvideValue(IXamlServiceProvider serviceProvider) + protected override object? ProvideValue(IXamlServiceProvider serviceProvider) { var root = ((IRootObjectProvider)serviceProvider.GetService(typeof(IRootObjectProvider))).RootObject; - var info = root.GetType().GetProperty(_propertyName); - return info.GetValue(root); + var info = root.GetType().GetProperty(Name); + return info?.GetValue(root); } } ``` @@ -115,7 +113,13 @@ The following XAML will display “Page Tag”: Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> - + + + + + + + ```