ViewActivated

Sep 28, 2011 at 7:32 PM

The IViewAwareStatus.ViewActivated Action is not called by default. (ony for Unittest?)

At wich point can I call this?

( e.g. to refresh data, if a existing view is activated via a tabbed interface)

Regardfs,

-christoph

Coordinator
Sep 29, 2011 at 8:36 AM
Edited Sep 29, 2011 at 8:37 AM

IViewAwareStatus.ViewActivated is only applicable to Window type objects. I have just checked the code and it is correct. I think in this case your understanding is incorrect. That event from the IViewAwareStatus service is ONLY ever going to be fired for Window when its Activated (which is one of the standard Window events).

See this link : http://msdn.microsoft.com/en-us/library/system.windows.window.activated.aspx

 

 

In the types of apps I mainly do there is only 1 window (ie the shell). This event has nothing to do with selection of a view becoming active. If you want that behaviour, you will have to roll your own attached behaviour to deal with that.

 

Hope that answers you query

Sep 29, 2011 at 9:35 AM

Hi Sacha,

ok.

Have you any tip how I can implement this (De-)Activated-behavior for the Cinch-Workspaces?

Coordinator
Sep 29, 2011 at 10:04 AM

I guess you would have to create a blend behaviour that targetted tabcontrol (so basically selector), and listened for selectionchanged event. Then when that happened you would need to find the tabcontrols content, and get the VM for that and then call a command in it which would tell you something about the active View.

 

Sep 29, 2011 at 2:32 PM
Edited Sep 29, 2011 at 2:57 PM

Good idea!

I found the event in your Demo-App, and expand this:

 

        /// update the visible child in the ItemsHolder
        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            base.OnSelectionChanged(e);
            UpdateSelectedItem();
            // new
            var cp = FindChildContentPresenter(GetSelectedTabItem());
            var ws = (WorkspaceData)cp.Content;
            var vm = (ViewModelBase)ws.ViewModelInstance;
            vm.OnViewActivated();     // new in ViewModelBase
        }

Is this a good way?

Coordinator
Sep 30, 2011 at 8:42 AM

Yeah I think that is exactly what you want