【发布时间】:2012-03-04 19:29:02
【问题描述】:
我在 app.xaml 文件中将边框 CornerRadius 覆盖为默认样式(如下所示)
<Application x:Class="BorderCornerProblem.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="CornerRadius" Value="50"/>
</Style>
</Application.Resources>
</Application>
在 MainWindow.xaml 文件中我有
<Window x:Class="BorderCornerProblem.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
</Window>
结果是窗口有一个黑色的圆角。
然后我的问题是如何定义一个 DefaultStyle 并为 Border 设置 CornerRadius 不会弄乱我的窗口?
【问题讨论】:
-
所以你想改变一些边框样式但不是全部?
-
嗯,是的。我想为我在 xaml 中显式使用的所有边框设置一种样式
标签: wpf border rounded-corners cornerradius