locked
changing view based on tab menu context RRS feed

  • Question

  • This is a WPF project, and I'm working on the xaml side, in blend.

    I'm using a tab control menu with three tabs.  The tab control sits on top of my grid.  In the grid I have a variety of elements that I would like to switch on and off based on what tab is currently selected.

    For example, on one tab 'view' I have a grid splitter and a listbox.  On the next tab, I want to collapse those when that tab is selected;  but if the user goes back to the first tab, to have the grid splitter and listbox be visible again.

    I've been playing with the RequestBringIntoView as well as got mouse focus without much success;  what event would recognize to 'play this movie' whenever the tab is loaded into view?  I had high hopes for RequestBringIntoView, but seems not to work for me.

    Any help would be appreciated.


    Purkiss
    Friday, November 27, 2009 4:22 PM

Answers

  • Ok, should have played around a little more!

    the event RequestBringIntoView is indeed the event you want to link into.

    Select the tab  (example:  tabOne) and then add the event RequestBringIntoView to it.  Create a movie that will trigger the changes in the view that you need (for example, collapsing grids, spreading content across multiple rows, etc, to alter the view)--all on frame one of the movie.  I called my movies  movOneView, movTwoView, etc.

    Seems to work good!
    Purkiss
    • Marked as answer by Purkiss Friday, November 27, 2009 4:37 PM
    Friday, November 27, 2009 4:37 PM

All replies

  • What you're doing is defeating the whole idea behind the TabControl, I think.  The TabControl has the behavior you are looking for built-in.  In other words, you should not be trying to handle tab selection events to switch grids.  If you simply put your grid inside of the TabItem (what you're using to create the tabs), it will work as you expect.

    I created a sample project for you to make things clearer.  You can download it here.
    Friday, November 27, 2009 4:36 PM
  • Ok, should have played around a little more!

    the event RequestBringIntoView is indeed the event you want to link into.

    Select the tab  (example:  tabOne) and then add the event RequestBringIntoView to it.  Create a movie that will trigger the changes in the view that you need (for example, collapsing grids, spreading content across multiple rows, etc, to alter the view)--all on frame one of the movie.  I called my movies  movOneView, movTwoView, etc.

    Seems to work good!
    Purkiss
    • Marked as answer by Purkiss Friday, November 27, 2009 4:37 PM
    Friday, November 27, 2009 4:37 PM
  • Sorry, maybe I misunderstood what you were trying to do here.  It sure sounded like you were trying to control the contents of the tabcontrol, but I guess you have a movie in the tabcontrol, and a separate grid elsewhere that you also want to appear.  You couldn't put the grid inside of the tabcontrol as well?
    Friday, November 27, 2009 4:40 PM
  • Hi Matsumoto,

    We are reusing some complex elements and altering the appearance around and inside that based on the tab...the tab changes the context.  Since we are using the same UserControl between tabs, but changing its context, we don't want to put a copy inside each tab control; so this is rather a special example. 
    Purkiss
    Monday, November 30, 2009 4:19 PM