/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/VisualStudio/Core/Def/Utilities/BindableTextBlock.cs
48 строк
2 KB
Cyrus Najmabadi
Make sealed
26 мар 2025, 22:21
26 мар 2025, 22:21
d99b771
Код
Авторство
О чём код?
// 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.ObjectModel; using System.Text; using System.Windows; using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Documents; namespace Microsoft.VisualStudio.LanguageServices.Utilities; internal sealed class BindableTextBlock : TextBlock { public IList<Inline> InlineCollection { get { return (ObservableCollection<Inline>)GetValue(InlineListProperty); } set { SetValue(InlineListProperty, value); } } public static readonly DependencyProperty InlineListProperty = DependencyProperty.Register(nameof(InlineCollection), typeof(IList<Inline>), typeof(BindableTextBlock), new UIPropertyMetadata(null, OnPropertyChanged)); private static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var textBlock = (BindableTextBlock)sender; var newList = (IList<Inline>)e.NewValue; textBlock.Inlines.Clear(); if (newList is null) { return; } var automationTextBuilder = new StringBuilder(); foreach (var inline in newList) { textBlock.Inlines.Add(inline); automationTextBuilder.Append(inline.GetText()); } AutomationProperties.SetName(textBlock, automationTextBuilder.ToString()); } }