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

  • SEARCH
  • Home
  • 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 8118091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:22:37+00:00 2026-06-06T04:22:37+00:00

I am experiencing a very weird problem: In WPF I have a tabControl which

  • 0

I am experiencing a very weird problem: In WPF I have a tabControl which contains 3 tabItems. I have made a binding from the tabControl’s SelectedIndex to a property inside my viewModel class in “OneWayToSource” mode.

Here’s the XAML code:

<TabControl Name="mainTabControl" SelectedIndex="{Binding SelectedTabIndex, Mode=OneWayToSource}"  >
        <TabItem Header="Tab 01" Name="tab01"> ... </TabItem>
        <TabItem Header="Tab 02" Name="tab02"> ... </TabItem>
        <TabItem Header="Tab 03" Name="tab03"> ... </TabItem>
</TabControl>

And in my viewModel:

    private int m_selectedTabIndex;
    public int SelectedTabIndex
    {
        get
        { return m_selectedTabIndex; }
        set
        {
            SetAndNotify(ref m_selectedTabIndex, value, () => SelectedTabIndex);
            SelectedTabChanged();
        }
    }

private void SelectedTabChanged()
    {
        // Some code
    }

As you can see, everytime my viewModel’s SelectedTabIndex property changes, the SelectedTabChanged() method is executed, this works perfectly.

My weird problem is that: When I show a message using for example System.Windows.MessageBox.Show("Some Text") inside my SelectedTabChanged() method, I select another tabItem and the previous selected tab gets blocked, it looks like selected, but it remains selected permanently, I cannot see its content anymore.

Just to clarify: As I stated before, this weird issue only happens when a modal window is showed

Why is happening? How can I solve this issue?

I hope I explained myself clearly.

Thank you in advance.

  • 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-06-06T04:22:39+00:00Added an answer on June 6, 2026 at 4:22 am

    I have solved my problem. Since I am new in WPF I really dont understand why a modal window make the tabs get blocked. But I was searching and found that the Dispatcher class allows one to execute asynchronously a method which prevent any control from get blocked.

    I changed my viewModel code as below:

    public int SelectedTabIndex
        {
            get
            { return m_selectedTabIndex; }
            set
            {
                SetAndNotify(ref m_selectedTabIndex, value, () => SelectedTabIndex);
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(SelectedTabChanged), null);
            }
        }
    

    The line that really helped me was the following:

    Dispatcher.CurrentDispatcher.BeginInvoke(new Action(SelectedTabChanged), null);
    

    Hope this help someone else can be experiencing some similar problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experiencing a (for me) very weird problem in Python. I have a class
I am experiencing very weird issues surrounding Images. I have a settings window, which
I'm experiencing a very curious problem. I have a list named theorems that has
I'm experiencing a very weird Javascript bug in Chrome. I've made a website for
I've been experiencing a very frustrating problem with a administrative website I have recently
I am experiencing something very tricky. I have two networks, one has internet access
I am experiencing some very odd timing behavior from a function I wrote. If
At the moment I am experiencing a very frustrating problem. I will try to
We are running MS SQL 2005 and we have been experiencing a very peculiar
So, I'm experiencing a very weird issue with my little test application. And by

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.