From cffaa7f7119bbeca2ca6132d08849ea0e97df4c8 Mon Sep 17 00:00:00 2001 From: Vincent Gromfeld Date: Fri, 22 Jan 2021 17:47:55 +0100 Subject: [PATCH 1/6] metadata control + sample app update --- .../Microsoft.Toolkit.Uwp.SampleApp.csproj | 12 ++ .../MetadataControl/MetadataControl.png | Bin 0 -> 883 bytes .../MetadataControl/MetadataControlCode.bind | 15 ++ .../MetadataControl/MetadataControlPage.xaml | 12 ++ .../MetadataControlPage.xaml.cs | 83 ++++++++ .../SamplePages/samples.json | 10 + .../MetadataControl/MetadataControl.cs | 194 ++++++++++++++++++ .../MetadataControl/MetadataControl.xaml | 15 ++ .../MetadataControl/MetadataUnit.cs | 37 ++++ .../Microsoft.Toolkit.Uwp.UI.Controls.csproj | 10 + .../Themes/Generic.xaml | 1 + 11 files changed, 389 insertions(+) create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControl.png create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlCode.bind create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml create mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.cs create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.xaml create mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataUnit.cs diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj index b0e9f84eb42..05b97d83c79 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj +++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj @@ -269,6 +269,7 @@ + @@ -497,6 +498,9 @@ FocusBehaviorPage.xaml + + MetadataControlPage.xaml + TilesBrushPage.xaml @@ -975,6 +979,14 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControl.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControl.png new file mode 100644 index 0000000000000000000000000000000000000000..63f5ef802c9ab316dcb19cb4355820dbdee84120 GIT binary patch literal 883 zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI4{)#n$t4^1Z39w_#X;^)4C~IxyaaMs(j9#r z85lP9bN@+X1@buyJR*x382FBWFymBhK53w!WQl7;NpOBzNqJ&XDnmhHW?qS2UTTSg ziJpO;k>N*$%&80vOpiTX978JN-rfn!YIYEDxVYr@iL6bZ)}&pVD74{%7^}3;dzN#I zg#!EK&dBb!={J0*-f-Y}5&MsFCYBTyjuRXL69g3$lpP%08X9^S7$q5*jE1$u%+C^! z_pRYC-WxYv^#0wv?WtdFHpiA9$&o)(emC&*-?QTA;W6vL)1se+g*u<-PG@M{X4cYM z#PfOXd{9Vry|HYZd+EIK{qG8h;Opu!oOX4a?fVVqYVJ3KRB_q*J=hvt@!GOJdEaN@ z1)Mdx9MX?X&y>d@2lMAi^Di;KdB{ET;)8I4>zLy=-}_Hs$0rrL$G|+n;OXk;vd$@? F2>=)o@QVNd literal 0 HcmV?d00001 diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlCode.bind new file mode 100644 index 00000000000..a0b052eb012 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlCode.bind @@ -0,0 +1,15 @@ + + + + + + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml new file mode 100644 index 00000000000..a43e28233f2 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml @@ -0,0 +1,12 @@ + + + + + + diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml.cs new file mode 100644 index 00000000000..49558eccd4d --- /dev/null +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml.cs @@ -0,0 +1,83 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.ObjectModel; +using Microsoft.Toolkit.Uwp.SampleApp.Common; +using Microsoft.Toolkit.Uwp.UI.Controls; +using Microsoft.Toolkit.Uwp.UI.Extensions; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages +{ + /// + /// A page that shows how to use the MetadataControl + /// + public sealed partial class MetadataControlPage : Page, IXamlRenderListener + { + private static readonly string[] Labels = "Lorem ipsum dolor sit amet consectetur adipiscing elit".Split(" "); + + private readonly Random _random; + private readonly ObservableCollection _units; + private readonly DelegateCommand _command; + private MetadataControl _metadataControl; + + public MetadataControlPage() + { + _random = new Random(); + _units = new ObservableCollection(); + _command = new DelegateCommand(OnExecuteCommand); + InitializeComponent(); + Setup(); + } + + public void OnXamlRendered(FrameworkElement control) + { + _metadataControl = control.FindChildByName("metadataControl") as MetadataControl; + if (_metadataControl != null) + { + _metadataControl.MetadataUnits = _units; + } + } + + private void Setup() + { + SampleController.Current.RegisterNewCommand("Add label", (sender, args) => + { + _units.Add(new MetadataUnit { Label = GetRandomLabel() }); + }); + + SampleController.Current.RegisterNewCommand("Add command", (sender, args) => + { + var label = GetRandomLabel(); + _units.Add(new MetadataUnit + { + Label = label, + Command = _command, + CommandParameter = label, + }); + }); + + SampleController.Current.RegisterNewCommand("Clear", (sender, args) => + { + _units.Clear(); + }); + } + + private string GetRandomLabel() => Labels[_random.Next(Labels.Length)]; + + private async void OnExecuteCommand(object obj) + { + var dialog = new ContentDialog + { + Title = "Command invoked", + Content = $"Command parameter: {obj}", + CloseButtonText = "OK" + }; + + await dialog.ShowAsync(); + } + } +} diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json index 5b356756f2d..cd5af28800d 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json @@ -136,6 +136,16 @@ "Icon": "/SamplePages/RadialProgressBar/RadialProgressBar.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/RadialProgressBar.md" }, + { + "Name": "MetadataControl", + "Type": "MetadataControlPage", + "Subcategory": "Status and Info", + "About": "The control displays a list of metadata separated by bullets. The entries can either be strings or commands.", + "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl", + "XamlCodeFile": "MetadataControlCode.bind", + "Icon": "/SamplePages/MetadataControl/MetadataControl.png", + "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/MetadataControl.md" + }, { "Name": "RotatorTile", "Type": "RotatorTilePage", diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.cs b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.cs new file mode 100644 index 00000000000..9dc6602eae7 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.cs @@ -0,0 +1,194 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Text; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation; +using Windows.UI.Xaml.Automation.Peers; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Documents; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// Display s separated by bullets. + /// + [TemplatePart(Name = TextContainerPart, Type = typeof(TextBlock))] + public sealed class MetadataControl : Control + { + /// + /// The DP to store the property value. + /// + public static readonly DependencyProperty SeparatorProperty = DependencyProperty.Register( + nameof(Separator), + typeof(string), + typeof(MetadataControl), + new PropertyMetadata(" • ", OnPropertyChanged)); + + /// + /// The DP to store the property value. + /// + public static readonly DependencyProperty AccessibleSeparatorProperty = DependencyProperty.Register( + nameof(AccessibleSeparator), + typeof(string), + typeof(MetadataControl), + new PropertyMetadata(", ", OnPropertyChanged)); + + /// + /// The DP to store the property value. + /// + public static readonly DependencyProperty MetadataUnitsProperty = DependencyProperty.Register( + nameof(MetadataUnits), + typeof(IEnumerable), + typeof(MetadataControl), + new PropertyMetadata(null, OnMetadataUnitsChanged)); + + private const string TextContainerPart = "TextContainer"; + + private TextBlock _textContainer; + + /// + /// Initializes a new instance of the class. + /// + public MetadataControl() + { + DefaultStyleKey = typeof(MetadataControl); + ActualThemeChanged += OnActualThemeChanged; + } + + /// + /// Gets or sets the separator to display between the . + /// + public string Separator + { + get => (string)GetValue(SeparatorProperty); + set => SetValue(SeparatorProperty, value); + } + + /// + /// Gets or sets the separator that will be used to generate the accessible string representing the control content. + /// + public string AccessibleSeparator + { + get => (string)GetValue(AccessibleSeparatorProperty); + set => SetValue(AccessibleSeparatorProperty, value); + } + + /// + /// Gets or sets he to display in the control. + /// If it implements , the control will automatically update itself. + /// + public IEnumerable MetadataUnits + { + get => (IEnumerable)GetValue(MetadataUnitsProperty); + set => SetValue(MetadataUnitsProperty, value); + } + + /// + protected override void OnApplyTemplate() + { + _textContainer = GetTemplateChild(TextContainerPart) as TextBlock; + Update(); + } + + private static void OnMetadataUnitsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = (MetadataControl)d; + void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) => control.Update(); + + if (e.OldValue is INotifyCollectionChanged oldNcc) + { + oldNcc.CollectionChanged -= OnCollectionChanged; + } + + if (e.NewValue is INotifyCollectionChanged newNcc) + { + newNcc.CollectionChanged += OnCollectionChanged; + } + + control.Update(); + } + + private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + => ((MetadataControl)d).Update(); + + private void OnActualThemeChanged(FrameworkElement sender, object args) => Update(); + + private void Update() + { + if (_textContainer is null) + { + // The template is not ready yet. + return; + } + + _textContainer.Inlines.Clear(); + + if (MetadataUnits is null) + { + AutomationProperties.SetName(_textContainer, string.Empty); + NotifyLiveRegionChanged(); + return; + } + + Inline unitToAppend; + var accessibleString = new StringBuilder(); + foreach (var unit in MetadataUnits) + { + if (_textContainer.Inlines.Count > 0) + { + _textContainer.Inlines.Add(new Run { Text = Separator }); + accessibleString.Append(AccessibleSeparator ?? Separator); + } + + unitToAppend = new Run + { + Text = unit.Label, + }; + + if (unit.Command != null) + { + var hyperLink = new Hyperlink + { + UnderlineStyle = UnderlineStyle.None, + Foreground = _textContainer.Foreground, + }; + hyperLink.Inlines.Add(unitToAppend); + + void OnHyperlinkClicked(Hyperlink sender, HyperlinkClickEventArgs args) + { + if (unit.Command.CanExecute(unit.CommandParameter)) + { + unit.Command.Execute(unit.CommandParameter); + } + } + + hyperLink.Click += OnHyperlinkClicked; + + unitToAppend = hyperLink; + } + + var unitAccessibleLabel = unit.AccessibleLabel ?? unit.Label; + AutomationProperties.SetName(unitToAppend, unitAccessibleLabel); + accessibleString.Append(unitAccessibleLabel); + + _textContainer.Inlines.Add(unitToAppend); + } + + AutomationProperties.SetName(_textContainer, accessibleString.ToString()); + NotifyLiveRegionChanged(); + } + + private void NotifyLiveRegionChanged() + { + if (AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) + { + var peer = FrameworkElementAutomationPeer.FromElement(this); + peer?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged); + } + } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.xaml new file mode 100644 index 00000000000..243ca9bd60d --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.xaml @@ -0,0 +1,15 @@ + + + + diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataUnit.cs b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataUnit.cs new file mode 100644 index 00000000000..b2cc1349e71 --- /dev/null +++ b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataUnit.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Windows.Input; + +namespace Microsoft.Toolkit.Uwp.UI.Controls +{ + /// + /// A unit of metadata to display in . + /// + public struct MetadataUnit + { + /// + /// Gets or sets the label of the unit. + /// + public string Label { get; set; } + + /// + /// Gets or sets the automation name that will be set on the unit. + /// If not set, will be used. + /// + public string AccessibleLabel { get; set; } + + /// + /// Gets or sets the command associated to the unit. + /// If null, the unit will be displayed as a text field. + /// If set, the unit will be displayed as an hyperlink. + /// + public ICommand Command { get; set; } + + /// + /// Gets or sets the parameter that will be provided to the . + /// + public object CommandParameter { get; set; } + } +} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj index 10577dbb847..23cbbf53ef7 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj @@ -64,6 +64,16 @@ + + + + + + + Designer + + + diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml index a6c650d3a4b..68520bd8d21 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml @@ -34,5 +34,6 @@ + \ No newline at end of file From 9dad997f8275f2cde394e5ba0a8434bc6bb21a40 Mon Sep 17 00:00:00 2001 From: Vincent Gromfeld Date: Fri, 22 Jan 2021 17:55:19 +0100 Subject: [PATCH 2/6] cleanup csproj --- .../Microsoft.Toolkit.Uwp.UI.Controls.csproj | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj index 23cbbf53ef7..22df93f1a72 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj @@ -25,6 +25,7 @@ - LayoutTransformControl: Support for transformations as if applied by LayoutTransform. - Loading: Helps to show content with animation to the user while the app is doing some calculation. - MasterDetailsView: Implements the Master/Details design pattern. + - MetadataControl: Displays a list of values separated by bullets with optional actionable links. - OrbitView: Positions items in a circle around a center element and supports orbits and anchors. - RadialGauge: Displays a value within a range, using a needle on a circular face. - RadialProgressBar: Displays progress as a circle getting filled. @@ -64,16 +65,6 @@ - - - - - - - Designer - - - From 5984f29d7ddcc9e724f1c35bec8028ebe0f2edc0 Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 9 Jun 2021 23:23:00 +0200 Subject: [PATCH 3/6] pr comments --- .../MetadataControlPage.xaml.cs | 10 ++-- .../MetadataControl/MetadataControl.cs | 46 +++++++++++++------ .../MetadataControl/MetadataControl.xaml | 10 ++-- .../{MetadataUnit.cs => MetadataItem.cs} | 14 +++--- 4 files changed, 49 insertions(+), 31 deletions(-) rename Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/{MetadataUnit.cs => MetadataItem.cs} (72%) diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml.cs index 49558eccd4d..3e296ac1a3b 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml.cs +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MetadataControl/MetadataControlPage.xaml.cs @@ -20,14 +20,14 @@ public sealed partial class MetadataControlPage : Page, IXamlRenderListener private static readonly string[] Labels = "Lorem ipsum dolor sit amet consectetur adipiscing elit".Split(" "); private readonly Random _random; - private readonly ObservableCollection _units; + private readonly ObservableCollection _units; private readonly DelegateCommand _command; private MetadataControl _metadataControl; public MetadataControlPage() { _random = new Random(); - _units = new ObservableCollection(); + _units = new ObservableCollection(); _command = new DelegateCommand(OnExecuteCommand); InitializeComponent(); Setup(); @@ -38,7 +38,7 @@ public void OnXamlRendered(FrameworkElement control) _metadataControl = control.FindChildByName("metadataControl") as MetadataControl; if (_metadataControl != null) { - _metadataControl.MetadataUnits = _units; + _metadataControl.Items = _units; } } @@ -46,13 +46,13 @@ private void Setup() { SampleController.Current.RegisterNewCommand("Add label", (sender, args) => { - _units.Add(new MetadataUnit { Label = GetRandomLabel() }); + _units.Add(new MetadataItem { Label = GetRandomLabel() }); }); SampleController.Current.RegisterNewCommand("Add command", (sender, args) => { var label = GetRandomLabel(); - _units.Add(new MetadataUnit + _units.Add(new MetadataItem { Label = label, Command = _command, diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.cs b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.cs index 9dc6602eae7..184ca44ba27 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.cs +++ b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.cs @@ -14,7 +14,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls { /// - /// Display s separated by bullets. + /// Display s separated by bullets. /// [TemplatePart(Name = TextContainerPart, Type = typeof(TextBlock))] public sealed class MetadataControl : Control @@ -38,13 +38,22 @@ public sealed class MetadataControl : Control new PropertyMetadata(", ", OnPropertyChanged)); /// - /// The DP to store the property value. + /// The DP to store the property value. /// - public static readonly DependencyProperty MetadataUnitsProperty = DependencyProperty.Register( - nameof(MetadataUnits), - typeof(IEnumerable), + public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register( + nameof(Items), + typeof(IEnumerable), typeof(MetadataControl), - new PropertyMetadata(null, OnMetadataUnitsChanged)); + new PropertyMetadata(null, OnMetadataItemsChanged)); + + /// + /// The DP to store the TextBlockStyle value. + /// + public static readonly DependencyProperty TextBlockStyleProperty = DependencyProperty.Register( + nameof(TextBlockStyle), + typeof(Style), + typeof(MetadataControl), + new PropertyMetadata(null)); private const string TextContainerPart = "TextContainer"; @@ -60,7 +69,7 @@ public MetadataControl() } /// - /// Gets or sets the separator to display between the . + /// Gets or sets the separator to display between the . /// public string Separator { @@ -78,13 +87,22 @@ public string AccessibleSeparator } /// - /// Gets or sets he to display in the control. + /// Gets or sets the to display in the control. /// If it implements , the control will automatically update itself. /// - public IEnumerable MetadataUnits + public IEnumerable Items + { + get => (IEnumerable)GetValue(ItemsProperty); + set => SetValue(ItemsProperty, value); + } + + /// + /// Gets or sets the to use on the inner control. + /// + public Style TextBlockStyle { - get => (IEnumerable)GetValue(MetadataUnitsProperty); - set => SetValue(MetadataUnitsProperty, value); + get => (Style)GetValue(TextBlockStyleProperty); + set => SetValue(TextBlockStyleProperty, value); } /// @@ -94,7 +112,7 @@ protected override void OnApplyTemplate() Update(); } - private static void OnMetadataUnitsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void OnMetadataItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = (MetadataControl)d; void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) => control.Update(); @@ -127,7 +145,7 @@ private void Update() _textContainer.Inlines.Clear(); - if (MetadataUnits is null) + if (Items is null) { AutomationProperties.SetName(_textContainer, string.Empty); NotifyLiveRegionChanged(); @@ -136,7 +154,7 @@ private void Update() Inline unitToAppend; var accessibleString = new StringBuilder(); - foreach (var unit in MetadataUnits) + foreach (var unit in Items) { if (_textContainer.Inlines.Count > 0) { diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.xaml index 243ca9bd60d..dea9a109cee 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/MetadataControl/MetadataControl.xaml @@ -1,13 +1,13 @@ - +