Advice needed - connecting MainPage with sub Views

    General discussion

  • Hi

    Can someone please give me some advice as to the 'best' structure for my current programming issue. Currently we have an application with a MainPage that consists of a Main and Sub Toolbar and a Content Frame - the frame is used to show the many different views that are accessed from a menu sitting in the Main Toolbar on the MainPage. Every time a new view is loaded the main page needs to consider the View's DataContext to determine which of many different dropdowns, selectors on the MainPage Sub Toolbar etc to show/hide. At the moment the way we handle this is to check the View's datacontext in the Navigated event in the MainPage.xaml.cs and modify the MainPage accordingly.

    I would like to change this for a number of reasons:

    (a) it relies on each View having had its datacontext already initialized before the Navigated event runs - as we start to use the MEF Import/Export approach more and more this no longer holds true;

    (b) it seems to me to be too 'tightly coupled' and I'd like to improve/overhaul it sooner rather than later

    Can anyone advise as to best practice and offer any links to similar examples?


    Thursday, March 03, 2011 6:00 AM

All replies