April 20th, 2009 10:31 PM
#1
Tab control Border visibility
IHi,
I am new to wpf and i am working windows apps i created WPF TabControl in my project that has a "2nd" border (right and bottom) I am unable to removed in any way.
I tried to Setting the BorderThickness=0,0,0,0 still leaves two lines on the right and bottom of the control. Can these be removed?
Thanks .
April 21st, 2009 08:10 AM
#2
Re: Tab control Border visibility
Setting BorderThickness to "0" will not work here. Though it removes all borders, still the shadow effect persists. To get around this, use the control templates.
Code:
<Style TargetType="{x:Type TabControl}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TabPanel
Name="HeaderPanel"
Grid.Row="0"
Panel.ZIndex="1"
Margin="0,0,4,-1"
IsItemsHost="True"
KeyboardNavigation.TabIndex="1"
Background="Transparent" />
<Border
Name="Border"
Grid.Row="1"
Background="White"
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="2"
KeyboardNavigation.TabNavigation="Local"
KeyboardNavigation.DirectionalNavigation="Contained"
KeyboardNavigation.TabIndex="2" >
<ContentPresenter
Name="PART_SelectedContentHost"
Margin="4"
ContentSource="SelectedContent" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="Gray" />
<Setter TargetName="Border" Property="BorderBrush" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Inspect the code, remove/add as per your requirement.
Put this code in the App.xaml file.
This will remove all the borders from the tab control.
You may also create a seperate resource file for a control template and add the reference of it in the App.xaml file.
Try this.. it will surely work.
Regards,
MMH
Rate my post if you find it usefull.
April 21st, 2009 08:49 AM
#3
Re: Tab control Border visibility
Thanks for your reply and it is working fine.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks