locked
Terminating execution in the OnViewChangeStarted event handler

    Question

  • We are using the OnViewChangeStarted and OnViewChangeCompleted event handlers to toggle between Semantic zoom in and zoom out events. As per the runtime, the event OnViewChangeStarted is fired before OnViewChangeCompleted. In case of going from zoom out to zoom in, we want to make a check before actually going to zoom in view. Basically when the OnViewChangeStarted event is fired, we want to check a value from the source item and if it is invalid, we want to prevent execution of OnViewChangeCompleted. Is there any way to achieve this?

    OnViewChangeStarted(Object^ sender, SemanticZoomViewChangedEventArgs^ e)

    {

        if(!e->IsSourceZoomedInView)

        {

            //Read variable value from e->SourceItem->Item

            //if item is invalid, do not propogate call to OnViewChangeCompleted. What can be done here?

        }

    }

    OnViewChangeCompleted(Object^ sender, SemanticZoomViewChangedEventArgs^ e)

    {

        if(!e->IsSourceZoomedInView)

        {

            //Process view change

        }

     

    }

    Wednesday, May 16, 2012 7:11 AM

All replies

  • Try to declare one bool flag variable that save the result of your validation, then you could in the OnViewChangeCompleted method to check this flag and decide  to continue or change the View back via code.

    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 17, 2012 10:02 AM
  • This would probably work, but it is not the most optimum solution. I would be essentially changing view from zoom out to zoom in and then depending on the variable, change back to zoom out. Maybe the user would see a flicker. This would be un-necessary if I could capture the ItemClick on the zoom out view (which doesnt happen for some reason) or cancel the event in the OnViewChangeStarted() handler itself before the view change actually happens. Any thoughts?
    Friday, May 18, 2012 5:59 AM