2012-02-13 93 views
1

我重写边界CornerRadius作为的App.xaml文件默认样式(如下图所示)重写默认风格让我的WPF窗口四舍五入

<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> 

结果是窗口有一个黑色的圆角。

我的问题,然后是如何定义DefaultStyleCornerRadius组为边境不会惹我的窗口?

+0

所以你想改变一些边框样式,但不是全部? – ChrisBD 2012-02-13 11:41:47

+0

好吧,是的。我想有一个样式的所有边界我使用**明确**在xaml – 4rchie 2012-02-13 11:50:48

回答

1

你真的应该不是全球风格Borders,它们无处不在。

给样式一个键,只在需要的时候引用它。

+0

我真的不喜欢你的答案,但它看起来像它的真实:(DataGrid也受到我的边框风格的影响。用自己的风格做我自己的控制,谢谢你的帮助 – 4rchie 2012-02-13 11:55:10