3

Closed

[Phone, Win8] OnViewReady should be called on child views too

description

I have a conductor that conducts pivot items, so I add items like this:
protected override void OnInitialize() {
  base.OnInitialize();

  Items.Add(_createItemFactory());

  ActivateItem(Items[0]);
}
Then I set a breakpoint in my child view model's OnViewReady and it never gets hit. The parent one gets hit, and the child's OnViewAttached and OnViewLoaded both trigger, but Ready doesn't.

Is that by design?
Closed Nov 2, 2013 at 3:20 PM by tibel

comments

kayub wrote Feb 23, 2013 at 3:43 PM

Yah, only Navigation Service calls OnViewReady. It would be nice if the conductor did so as well, so the child can know when it's parent page is ready.

kayub wrote Feb 23, 2013 at 3:54 PM

Actually, scratch that, I need to know when the associated child view's OnViewReady fires, not the parent.

tibel wrote Feb 26, 2013 at 5:02 PM

May you attach a sample project that shows the issue, please.
As creating a sample often takes longer than finding/fixing the issue.

kayub wrote Mar 2, 2013 at 7:21 PM

Will do, thanks.

tibel wrote Mar 8, 2013 at 3:16 PM

You were right: OnViewReady() is only called for the root ViewModel.
And you want it to be called on child ViewModels too?

kayub wrote Mar 15, 2013 at 3:22 PM

It would be nice if it was called whenever the associated view is ready, just as you'd expect if the view model was for a page. I typically have user controls as my pivot/panorama items, and they usually need to populate controls, so I was hoping to use OnViewReady to do that after the layout has been loaded.

tibel wrote Oct 6, 2013 at 8:13 AM

Will it work when we move the code from FrameAdapter.OnNavigated() to ViewAware.AttachView()?
Then it should work for child views and also for views not opend via navigation (e.g. for Silverlight and WPF).
var viewAware = viewModel as IViewAware;
if(viewAware != null) {
  View.ExecuteOnLayoutUpdated(page, (s, a) => viewAware.OnViewReady(page));
}