Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 以ImageBrush作为前景的UWP Underline Textblock不显示下划线_C#_Uwp_Windows 10_Textblock_Underline - Fatal编程技术网

C# 以ImageBrush作为前景的UWP Underline Textblock不显示下划线

C# 以ImageBrush作为前景的UWP Underline Textblock不显示下划线,c#,uwp,windows-10,textblock,underline,C#,Uwp,Windows 10,Textblock,Underline,我正在使用图像画笔作为文本块前景。它工作正常,但当文本块为下划线时,该行不显示 复制。在XAML中 <TextBlock x:Name="textBlock" FontSize="80" FontWeight="Bold"> <Underline>This is my text</Underline> </TextBlock> 下面是应用下划线的SolidColorBrush的外观 然后,当应用ImageBrush时,下划线消失 所以

我正在使用
图像画笔
作为
文本块
前景
。它工作正常,但当
文本块
下划线
时,该行不显示

复制。在XAML中

<TextBlock x:Name="textBlock" FontSize="80" FontWeight="Bold">
    <Underline>This is my text</Underline>
</TextBlock>
下面是应用下划线的SolidColorBrush的外观

然后,当应用
ImageBrush
时,下划线消失

所以我的问题是如何将
ImageBrush
前景
应用到UWP中的
下划线
文本块

所以我的问题是如何将ImageBrush前景应用于UWP中的下划线文本块

默认情况下,当
ImageBrush
应用于
TextBlock
前台
属性时,下划线将被删除

解决方法用于模拟下划线:

<Border BorderThickness="0, 0, 0, 2" Height="{Binding ActualHeight, ElementName=textBlock}" Width="{Binding ActualWidth, ElementName=textBlock}">
            <Border.BorderBrush>
                <ImageBrush ImageSource="Assets/0.jpg" />
            </Border.BorderBrush>
            <TextBlock x:Name="textBlock" FontSize="50" FontWeight="Bold">
                <TextBlock.Foreground>
                    <ImageBrush ImageSource="Assets/0.jpg" />
                </TextBlock.Foreground>
                <Underline><Run Text="This is my text"/></Underline>
            </TextBlock>
        </Border>


您可以创建UserControl/CustomControl以保持可重用性。

请注意,这不是真正的下划线,并且不考虑图示符高度和偏移。这在预览中可见,此时下划线被推到“y”中的最低点下方,而不是与其下一个点相交。
<Border BorderThickness="0, 0, 0, 2" Height="{Binding ActualHeight, ElementName=textBlock}" Width="{Binding ActualWidth, ElementName=textBlock}">
            <Border.BorderBrush>
                <ImageBrush ImageSource="Assets/0.jpg" />
            </Border.BorderBrush>
            <TextBlock x:Name="textBlock" FontSize="50" FontWeight="Bold">
                <TextBlock.Foreground>
                    <ImageBrush ImageSource="Assets/0.jpg" />
                </TextBlock.Foreground>
                <Underline><Run Text="This is my text"/></Underline>
            </TextBlock>
        </Border>