gpt4 book ai didi

WPF 圆角文本框

转载 作者:行者123 更新时间:2023-12-03 07:28:52 25 4
gpt4 key购买 nike

我不了解 WPF,现在正在学习。我在 WPF 中寻找圆角 TextBox 。所以我搜索了Google并找到了一段XAML:

 <!–Rounded Corner TextBoxes–>
<ControlTemplate x:Key=”RoundTxtBoxBaseControlTemplate” TargetType=”{x:Type Control}”>
<Border Background=”{TemplateBinding Background}” x:Name=”Bd” BorderBrush=”{TemplateBinding BorderBrush}”
BorderThickness=”{TemplateBinding BorderThickness}” CornerRadius=”6″>
<ScrollViewer x:Name=”PART_ContentHost”/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property=”IsEnabled” Value=”False”>
<Setter Property=”Background” Value=”{DynamicResource {x:Static SystemColors.ControlBrushKey}}” TargetName=”Bd”/>
<Setter Property=”Foreground” Value=”{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}”/>
</Trigger>
<Trigger Property=”Width” Value=”Auto”>
<Setter Property=”MinWidth” Value=”100″/>
</Trigger>
<Trigger Property=”Height” Value=”Auto”>
<Setter Property=”MinHeight” Value=”20″/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

所以请告诉我将此 XAML 粘贴到哪里。请详细帮助我。我是 WPF 的初学者。

最佳答案

@Smolla 在对 @Daniel Casserly 的回答的评论中给出了更好的答案:

<TextBox Text="TextBox with CornerRadius">
<TextBox.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="3"/>
</Style>
</TextBox.Resources>
</TextBox>

如果您希望文本框和列表框的所有边框都有圆角,请将样式放入您的窗口或应用程序的<Resources> .

关于WPF 圆角文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4779777/

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