TextBlock 下划线问题

issue with TextBlock Underline

我有下面的 Xaml 代码,我试图根据 bool condition.When 条件为 true 为文本块内容加下划线 它按预期工作(下划线可见)但是当条件为 false 时下划线仍然坚持(当条件为假时下划线不应该可见)

<TextBlock Text="Name" TextDecorations="{x:Bind Model.NameError, Converter={StaticResource TextUnderlineConverter}, Mode=OneWay}"

转换器代码

public class TextUnderlineConverter : IValueConverter
    {
public object Convert(object value, Type targetType, object parameter, string language)
        {
            if ((bool)value)
                return TextDecorations.Underline;
            else
               return TextDecorations.None;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }

@Venkat 感谢您的反馈。这是一个已知问题。相关团队正在调查此问题。

目前有一个解决方法,您可以为 TextBlock.

下的 Run 节点设置 TextDecorations
<TextBlock>
    <Run Text="Test Hello" TextDecorations="{x:Bind Flag, Converter={StaticResource ConverterText},Mode=OneWay}" />
</TextBlock>

UWP 中的错误,如下 Xaml 所示:

            <TextBlock>
                <Run  Text="Decorations can be toggled on and off"/>
            </TextBlock>

            <TextBlock Text="Decorations will not toggle off"/>

如果用 C# 编写 TextBlock 也会出现同样的问题

    TextBlock textBlock = new TextBlock { FontSize = 18.0 };
    textBlock.Inlines.Add(new Windows.UI.Xaml.Documents.Run { Text = "This text will not stick on text decoration." });

    TextBlock textBlockBad = new TextBlock
    {
        FontSize = 18.0,
        Text = "This text will not enable the TextDecorations to be turned off"
    };