TabControl Border problem

I'm seeing a strange border artifact when setting BorderThickness="0" ... the border is still being drawn on right and bottom sides of the control... How do I get rid of that

<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Background="sc#1, 0, 0, 0"
Width="640" Height="480">

<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<TabControl Margin="155,119,167,116" BorderThickness="0" Background="Transparent" RenderTransformOrigin="0.5,0.5" IsSynchronizedWithCurrentItem="True">
<TabItem Width="64" Height="17" Background="#FFFCFCFE" RenderTransformOrigin="0.5,0.5" Header="TabItem"/>
</TabControl>
</Grid>



Answer this question

TabControl Border problem

  • Craig Murphy

    As in this case... :) As John points out, please free to file bugs directly into our databases using that link if you think something is not correct.

    However, in this case, the default theme templates are often designed to reflect the looks of the Win32 controls (and this may result in not everything being perfectly configurable as you are finding out). Even if everything was configurable, you may not get the same behvior on a different OS like Vista.

    I would recommend:
    a) Decide if you want your application (or part of application's) UI is to be theme-dependent. In this case, leave everything to the theme system.
    b) If you want to enforce a look, take complete control of the template, and do not depend on the theme (maybe except for things like Font settings).

    Thanks,
    -Unni



  • tour_of_delusion

    Should this be reported as a bug Is it enough to just do it through this forum if no, How do I do that
  • Seifer

    Setting BorderBrush="Transparent" does not fix it....

    <Grid
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    Background="sc#1, 0, 0, 0"
    Width="640" Height="480">

    <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
    <RowDefinition/>
    </Grid.RowDefinitions>
    <TabControl Margin="155,119,167,116" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" RenderTransformOrigin="0.5,0.5" IsSynchronizedWithCurrentItem="True">
    <TabItem Width="64" Height="17" Background="#FFFCFCFE" RenderTransformOrigin="0.5,0.5" Header="TabItem"/>
    </TabControl>
    </Grid>


  • Alexander Futoryan

    Sometimes the Microsofties go through the posts looking for open issues, but I wouldn't depend on it. You can post bugs here:

    http://lab.msdn.microsoft.com/productfeedback/default.aspx

    The next WinFX/WPF CTP should be coming soon. WinHEC finishes this week, and I've read in forums that a new drop of Windows Vista is coming, so we can hope that a new WPF CTP is coming as well.

    I've just noticed that something I've written with a TabControl in it doesn't have the problem you've mentioned, but I've set up a style for it like this (borrowed from http://notstatic.com/):

    I have a file called TabControl.xaml in my Resources directory like this:

    <ResourceDictionary

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

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

    <Border

    Name="Border"

    Grid.Row="1"

    Background="#40777777"

    BorderBrush="Black"

    BorderThickness="1"

    CornerRadius="2"

    KeyboardNavigation.TabNavigation="Local"

    KeyboardNavigation.DirectionalNavigation="Contained"

    KeyboardNavigation.TabIndex="2" >

    <ContentPresenter

    Name="PART_SelectedContentHost"

    Margin="4"

    ContentSource="SelectedContent" />

    </Border>

    <TabPanel

    Name="HeaderPanel"

    Grid.Row="0"

    Margin="1,0,0,-1"

    IsItemsHost="True"

    KeyboardNavigation.TabIndex="1"

    Background="Transparent" />

    </Grid>

    <ControlTemplate.Triggers>

    <Trigger Property="IsEnabled" Value="False">

    <Setter Property="Foreground" Value="#40000000"/>

    <Setter TargetName="Border" Property="BorderBrush" Value="Black" />

    </Trigger>

    </ControlTemplate.Triggers>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </Style>

    </ResourceDictionary>

    and then in my xaml file that contains the TabControl I have this:

    <Grid.Resources>

    <ResourceDictionary>

    <ResourceDictionary.MergedDictionaries>

    <ResourceDictionary Source="Resources\TabControl.xaml" />

    </ResourceDictionary.MergedDictionaries>

    </ResourceDictionary>

    </Grid.Resources>


  • vdovjak

    Sorry I should have tested that before posting it. There seems to be a bit of a problem there with TabControl. The best solution I could come up with is this:

    <Grid

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    Background="sc#1, 0, 0, 0"

    Width="640" Height="480">

    <Grid.ColumnDefinitions>

    <ColumnDefinition/>

    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>

    <RowDefinition/>

    </Grid.RowDefinitions>

    <Grid Margin="155,119,167,116" ClipToBounds="True">

    <TabControl Margin="0,0,-1,-1" Background="Transparent" BorderThickness="0" RenderTransformOrigin="0.5,0.5" IsSynchronizedWithCurrentItem="True">

    <TabItem Width="64" Height="17" Background="#FFFCFCFE" RenderTransformOrigin="0.5,0.5" Header="TabItem"/>

    </TabControl>

    </Grid>

    </Grid>

    which is sort of cheating because I'm clipping the TabControl with another container.


  • Scott B. Arbeit

    <TabControl BorderBrush="Transparent">
  • TabControl Border problem