Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6362843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:57:39+00:00 2026-05-24T23:57:39+00:00

Unless I’m mistaken (which I hope I am) there is a bug with the

  • 0

Unless I’m mistaken (which I hope I am) there is a bug with the TabControl related to the visibility of TabItems.
Here’s XAML that reproduces the bug.

<UserControl x:Class="TabControl_bug.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Background="White">
        <sdk:TabControl>
            <sdk:TabItem Header="tabItem1"  Visibility="Collapsed">
                <TextBlock Text="TabItem1 which should not be visible" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            </sdk:TabItem>
            <sdk:TabItem Header="tabItem2">
                <TextBlock Text="TabItem2 which should be visible" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            </sdk:TabItem>
        </sdk:TabControl>
    </Grid>
</UserControl>

When you run this code, you’ll see that TabItem2 is not “selected” and so the content that is displayed is

TabItem 1 which should not be visible

Once you select the tab, then of course the TabItem2 content is displayed, and there’s no way of getting back to tabItem1, but the issue is in the inital display.

If I set the SelectedIndex property to 1 the correct content is displayed. Howerver I don’t know in the XAML which the of the Tabs should be selected first.

What workarounds are possible for this issue. Ideally the tabcontrol have preselected it’s first visable tabitem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:57:39+00:00Added an answer on May 24, 2026 at 11:57 pm

    I’ve found next solution.For your sample in MainPage constructor:

    tabControl.SetValue(TabControl.SelectedContentProperty, null);
    

    Also you can do that on Loaded event.

    Unfortunately, TabControl.SelectedContent property doesn’t have public setter so you can set SelectedContentProperty directly.

    EDIT:

    Behavior for this functionality:

    public class UnselectContentBehavior : Behavior<TabControl>
    {
            protected override void OnAttached()
            {
                base.OnAttached();
                AssociatedObject.Loaded += OnLoaded;
            }
    
            private void OnLoaded(object sender, RoutedEventArgs e)
            {
                AssociatedObject.SetValue(TabControl.SelectedContentProperty, null);
            }
    
            protected override void OnDetaching()
            {
                base.OnDetaching();
                AssociatedObject.Loaded -= OnLoaded;
            }
     }
    

    Using sample:

           <sdk:TabControl x:Name="tabControl">
                <sdk:TabItem Header="tabItem1"  Visibility="Collapsed">
                    <TextBlock Text="TabItem1 which should not be visible" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                </sdk:TabItem>
                <sdk:TabItem Header="tabItem2">
                    <TextBlock Text="TabItem2 which should be visible" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                </sdk:TabItem>
    
                <i:Interaction.Behaviors>
                    <b:UnselectContentBehavior/>
                </i:Interaction.Behaviors>
            </sdk:TabControl> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that -O2 is always generated unless I specify optimize-speed (which results in
I have always understood (unless im mistaken) that Apache's modrewrite engine requires Options +FollowSymLinks
There is a banking site that I cannot login to unless I allow all
I noticed that unless I re-call VertexAttribPointer, there's not input to shaders after a
I do realize that I can do unless [1].empty? But I'm wondering if there
Unless I'm mistaken, creating a function in Python works like this: def my_func(param1, param2):
The code below works unless p.School.SchoolName turns out to be null, in which case
My view is that unless you need to change the basic structure of the
Unless I'm wrong it seems like either works just fine - is there a
Unless I'm missing something, it seems that none of the APIs I've looked at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.