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>