locked
Does TabControl work with Canvas inside a Grid? RRS feed

  • Question

  • I am having problems getting a tab control to display inside a canvas that itself is inside a grid.

    Here is the simplified XAML code... what am I doing wrong, or is this not supported?  I get a runtime error.

    RC

    <Grid x:Name="LayoutRoot" Background="White">

            <Grid.RowDefinitions>

                <RowDefinition Height="20*"></RowDefinition>

                <RowDefinition Height="10*"></RowDefinition>

            </Grid.RowDefinitions>

           

            <Grid Grid.Row="0">

     

      <Canvas Margin="3" Background="Blue">

    <basics:TabControl>

    </basics:TabControl>   

                </Canvas>

                   

            </Grid>

            <Grid Grid.Row="1">

          </Grid>

    </Grid>

    Sunday, November 29, 2009 8:53 PM

Answers

  • I did more digging.  Turns out even following this helpful screenshot blog: http://blogs.silverlight.net/blogs/justinangel/archive/2008/10/30/silverlight-toolkit-dockpanel.aspx 

    I could not get DockPanel to show up.  It seems DockPanel is not even present in my controls (when I expand the "+" in the System.Window.Controls I seem to have everything but DockPanel..I do have "Dock" and "GridSplitter" but no DockPanel).

    I am using Silverlight Projects 2008 in the free version of Visual Studio Web Developer 2008.

    I don't want to reinstall if I can help it (the last time took me a whole day).

    If you know when Silverlight 2010 comes out, I might just wait for that version then do a clean install of that... in the meantime, I'll live without dockpanel. and TabControl (which strangely shows up but doesn't get recognized).

    Thanks for your help D. Matsumoto.

    • Marked as answer by RonConger09 Friday, December 4, 2009 1:22 AM
    Thursday, December 3, 2009 7:19 PM
  • Whoa, weird!  I wonder why that is missing... I wasn't using anything special as far as I could tell.  I was running on a PC that only has Blend installed, and nothing more.
    • Marked as answer by RonConger09 Friday, December 11, 2009 7:40 PM
    Friday, December 4, 2009 6:47 AM

All replies

  • Works fine for me.  What is the "basic" namespace?  By default, you shouldn't have had to do this unless you're using a different TabControl.
    Monday, November 30, 2009 3:07 AM
  • I took out "basics" and it would not compile.

    Error 1 The type 'TabControl' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. 

    NOTE:  this is a Silverlight app.

    Do you think I'm missing some sort of assembly? I do have the toolbar for adding buttons, textblocks, etc, so you would think it should work.  Also I've gotten Tab to work in WPF.  Doesn't Silverlight support it?

    RC
    Thursday, December 3, 2009 7:00 PM
  • I did more digging.  Turns out even following this helpful screenshot blog: http://blogs.silverlight.net/blogs/justinangel/archive/2008/10/30/silverlight-toolkit-dockpanel.aspx 

    I could not get DockPanel to show up.  It seems DockPanel is not even present in my controls (when I expand the "+" in the System.Window.Controls I seem to have everything but DockPanel..I do have "Dock" and "GridSplitter" but no DockPanel).

    I am using Silverlight Projects 2008 in the free version of Visual Studio Web Developer 2008.

    I don't want to reinstall if I can help it (the last time took me a whole day).

    If you know when Silverlight 2010 comes out, I might just wait for that version then do a clean install of that... in the meantime, I'll live without dockpanel. and TabControl (which strangely shows up but doesn't get recognized).

    Thanks for your help D. Matsumoto.

    • Marked as answer by RonConger09 Friday, December 4, 2009 1:22 AM
    Thursday, December 3, 2009 7:19 PM
  • Hi RC,

    I looked into it and yes, I see why you're having a problem.  Thanks for telling me you're using Silverlight, or I'd be really stumped.  :)

    Anyhow, you need to right click on your project and choose Add Reference.  Then add a reference to System.Windows.Controls in c:\Program Files\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.Windows.Controls.dll.  Then it should work for you.

    I've attached my sample solution for you here so you can check it out.  If this works for you, please mark your question as answered.  Thanks!
    Thursday, December 3, 2009 9:58 PM
  • ---------------------------
    Visual Web Developer 2008 Express Edition
    ---------------------------
    Unable to read the project file 'TabControlCanvasGrid2.csproj'.

     The imported project "C:\Program Files\MSBuild\Microsoft\Silverlight\V3.0\Microsoft.Silverlight.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
    ---------------------------
    OK   Cancel  
    ---------------------------

    Sorry, did not work!  But I appreciate the response anyway.  Don't sweat it D. Matsumoto--at this point TabControl is eye candy...I'm using Pages now, and it's about the same thing...I'll wait for Silverlight 2010.  Layout is important but there's many ways to skin the cat I find, so if one thing doesn't work I try another.  Still, it would be nice to have DockPanel and TabControl, though many people I suspect would not know how to use TabControl (I notice newbies on computers only click on arrow buttons, not tabs).

    RC

    Thursday, December 3, 2009 11:59 PM
  • Whoa, weird!  I wonder why that is missing... I wasn't using anything special as far as I could tell.  I was running on a PC that only has Blend installed, and nothing more.
    • Marked as answer by RonConger09 Friday, December 11, 2009 7:40 PM
    Friday, December 4, 2009 6:47 AM
  • I upgraded to Silverlight 3 and using drag and drop as well as this tutorial got tab control to work in Web Developer: http://www.c-sharpcorner.com/UploadFile/mahesh/SilverlightTabControl07022008170702PM/SilverlightTabControl.aspx 


    Thanks.
    Friday, December 11, 2009 7:40 PM