WPF TabControl XP 样式问题
我正在运行 Windows 7 的 PC 上设计 TabControl 的样式,一切看起来都很好,但是当我尝试在 Windows XP 中运行它时,TabControl 周围有一个可怕的白色边框:
我相信这是与 luna 战斗的相同问题(此处描述 TabControl without border wpf (XP)),但我不知道要在模板中更改什么...
TabControl 的样式如下:
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border Name="Border" Margin="0,10,0,-10" BorderBrush="Transparent" BorderThickness="1,1,0,0" CornerRadius="5,0,0,5">
<Border.Background>
<LinearGradientBrush EndPoint="1.407,0.5" StartPoint="-0.407,0.5">
<GradientStop Color="#49000000" Offset="0"/>
<GradientStop Offset="1" Color="#09FFFFFF"/>
</LinearGradientBrush>
</Border.Background>
<ContentPresenter x:Name="ContentSite"
TextBlock.FontSize="15"
TextBlock.Foreground="#22ffffff"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="5,5,2,5"
RecognizesAccessKey="True">
<ContentPresenter.LayoutTransform>
<RotateTransform Angle="270" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="100" />
<Setter TargetName="Border" Property="Background" Value="Red" />
<Setter TargetName="Border" Property="BorderThickness" Value="1,1,0,0" />
<Setter TargetName="ContentSite" Property="TextBlock.Foreground" Value="White"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="Background" Value="DarkRed" />
<Setter TargetName="Border" Property="BorderBrush" Value="Black" />
<Setter Property="Foreground" Value="DarkGray" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
实际的 TabControl' XAML(没什么花哨的)是:
<TabControl Grid.Row="1" Grid.Column="0" Margin="5,5" TabStripPlacement="Left"
Background="Transparent" HorizontalAlignment="Stretch" BorderThickness="0,0,0,0">
<TabControl.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="270"/>
</TabControl.BitmapEffect>
<TabItem Header="Tab Item 1"/>
<TabItem Header="Tab Item 2"/>
<TabItem Header="Tab Item 3"/>
<TabItem Header="Tab Item 4"/>
</TabControl>
任何帮助将不胜感激!
I'm working on styling a TabControl on a PC runnnig Windows 7 and everything looked fine, but when I tried running it in Windows XP, I get a hideous white border around the TabControl:
I believe it's the same problem fighting with luna (described here TabControl without border wpf (XP)), but I'm at a loss as to what to change in the template...
The style for the TabControl is as follows:
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border Name="Border" Margin="0,10,0,-10" BorderBrush="Transparent" BorderThickness="1,1,0,0" CornerRadius="5,0,0,5">
<Border.Background>
<LinearGradientBrush EndPoint="1.407,0.5" StartPoint="-0.407,0.5">
<GradientStop Color="#49000000" Offset="0"/>
<GradientStop Offset="1" Color="#09FFFFFF"/>
</LinearGradientBrush>
</Border.Background>
<ContentPresenter x:Name="ContentSite"
TextBlock.FontSize="15"
TextBlock.Foreground="#22ffffff"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="5,5,2,5"
RecognizesAccessKey="True">
<ContentPresenter.LayoutTransform>
<RotateTransform Angle="270" />
</ContentPresenter.LayoutTransform>
</ContentPresenter>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="100" />
<Setter TargetName="Border" Property="Background" Value="Red" />
<Setter TargetName="Border" Property="BorderThickness" Value="1,1,0,0" />
<Setter TargetName="ContentSite" Property="TextBlock.Foreground" Value="White"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="Background" Value="DarkRed" />
<Setter TargetName="Border" Property="BorderBrush" Value="Black" />
<Setter Property="Foreground" Value="DarkGray" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
and the actual TabControl' XAML (nothing fancy) is:
<TabControl Grid.Row="1" Grid.Column="0" Margin="5,5" TabStripPlacement="Left"
Background="Transparent" HorizontalAlignment="Stretch" BorderThickness="0,0,0,0">
<TabControl.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="270"/>
</TabControl.BitmapEffect>
<TabItem Header="Tab Item 1"/>
<TabItem Header="Tab Item 2"/>
<TabItem Header="Tab Item 3"/>
<TabItem Header="Tab Item 4"/>
</TabControl>
any help would be much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了一个解决方案,正常方法 - 将一个简单样式的控件分开:)
这是我必须添加的样式,以删除该边框,以防有人感兴趣:
Found a solution, normal method - pull a simple styled control in blend apart :)
Here's the style I had to add to remove that border in case anyone is interested: