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 .
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.
Re: Tab control Border visibility
Thanks for your reply and it is working fine.