Link to home
Start Free TrialLog in
Avatar of foliage_
foliage_Flag for Australia

asked on

Visual Studio C# WPF tabControl, can't change tab in visual editor?

I have made a very simple project in visual studio C# using WPF. Now I have created 3 tabs and added buttons to them all via the XML code manually. Now when I compile the app I can change tabs and all the buttons work as expected.

Now for the problem. In the visual editor I cannot change tabs, I can only view the first tab that was created and use the visual editor here. If I try clicking on the 2nd tab it just will not change.

I have sent my project to a friend who has Visual Studio 2008 and he can change tabs in the identical project however no matter what I do I cannot. I have tried everything short of reinstalling Visual studio.

Does anyone have any idea what could be causing this problem? There doesn't appear to be any issues with my project it all compiles with no warnings.

I have tried making a new project but they all suffer the same problem providing I use WPF, if I use a windows form project I do not have this issue with tabControl.

Thank you.
Avatar of foliage_
foliage_
Flag of Australia image

ASKER

Just reinstalled Visual studio and still the same.
I've found a really dodgy way to select tabs for the time being, if I delete all the tabs but the one I want, then press control + Z for as many tabs as I deleted, it will change and not remove anything.

Annoying as <expletive deleted>, but it will have to do for now.
Appears my problem is more I can't seem to use the visual editor with tabcontrol. The buttons I had were not actually on any of the tabs.

Anyone know any guides on how to work with tabs using the VISUAL editor, I can't be bothered writing it all manually as it is just a simple program, just want to drag and drop buttons and texboxes where I want them.
Avatar of Bob Learned
I would like to help you, but I only have .NET 2010 installed, and I think that it is important to know what version you are using, because it might be fixed in 2010.
um visual studio 2008 and whatever .net it comes with, 3.5 I think.
With the 2010, and the attached XAML, I am able to click on the tabs, and the property grid changes:


<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:System;assembly=mscorlib" 
    xmlns:c="clr-namespace:System.Collections;assembly=mscorlib" 
    xmlns:winf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    xmlns:my1="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
    Title="Window1" Height="362" Width="601">
    <Grid>
        <TabControl HorizontalAlignment="Stretch">
            <TabItem Header="Tab 1">
            </TabItem>
            <TabItem Header="Tab 2">
            </TabItem>
        </TabControl>
    </Grid>
</Window>

Open in new window

I can host the project if that would help people with helping me?
I don't believe that the problem is with the code, so that wouldn't help me.  Are you saying that when you click on the tabs in the designer, that nothing is changing on the Property window?
No the propertie window changes, but the visual tab does not change.

Think of it this way, you have the compiled project with 3 tabs running, you can click each tab and it will show a different window.

Using windows form projects the same functionality occurs in designer, as in you click a tab, drag and drop the textboxs, buttons etc onto it, click another tab, drag and drop what you want. Compile and it all works as expected.

However with WPF when you click the tabs, the window does not actually change, you are still stuck on the one single tab, no matter how many tabs you add to the project, you cannot actually VIEW the other tabs in the designer, you can only view them via the compiled project.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'll grab a copy of 2010 and report back.
Upgrading to 2010 seems to have rectified the problem.

Thanks.
Avatar of patrikmichnac
patrikmichnac

I have same problem and I am very sad about that. Is here anyopne who can help us? I have big project in Visual Studio 2008. It is not easy to install new studio 2010. In my editor there is one form with tabcontrol. If I click on tab page it doesn't change. I have still first page selected. IO can put any other contreol in other than first tab page.
I tried basically everything and have since found the problem exists on a friends 2008 installation also, not sure if it is platform wide or just specific to some configurations.

The only workaround I found was to delete all the tabs but the one you want to view, control z all the tabs back and it will have switched to the one you want. Annoying and tedious, but it did work.

Perhaps submit a request to Microsoft for help? You never know, they might actually answer you in a timely fashion.