gpt4 book ai didi

wpf - 如何使标签文本下划线?

转载 作者:行者123 更新时间:2023-12-03 21:02:33 46 4
gpt4 key购买 nike

如何在WPF中将Label文本设为Underline?我被卡住了,找不到下划线的任何属性:

<Label Name="lblUserName"
Content="Username"
FontSize="14" FontWeight="Medium" />

最佳答案

Label no TextDecorations 中,因此请尝试以下操作:

<Label Width="100" Height="30">
<TextBlock TextDecorations="Underline">TestText</TextBlock>
</Label>

Edit: more universal solution

在这种情况下,不要使用 Label.Content代替 Label.Tag,因为Content属性只能设置一次:
<Label Tag="TestContent" 
Width="100"
Height="30"
HorizontalContentAlignment="Center"
Background="AliceBlue">

<TextBlock TextDecorations="Underline"
Text="{Binding Path=Tag,
RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type Label}}}" />
</Label>

关于wpf - 如何使标签文本下划线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22609341/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com