locked
PageFunction<> question RRS feed

  • Question

  • in my PageFunction<> page i'm calling OnReturn like this:

     

    Code Snippet

    protected void btnOk_Click(object sender, RoutedEventArgs e)

    {

    if (this.lstAssets.SelectedItem != null)

    {

    OnReturn(new ReturnEventArgs<INVENTORYPLUS.ENTITIES.< FONT>Asset>(this.lstAssets.SelectedItem as Entities.Asset));

    }

    }

     

    but it's not firing the event i assigned here:

     

    Code Snippet

    void Window1_OpenAssetsCommandExecuting(object sender, RoutedEventArgs e)

    {

    ChooseAssetPage page = new ChooseAssetPage(new Services.AssetService());

    page.Return += new System.Windows.Navigation.ReturnEventHandler<INVENTORYPLUS.ENTITIES.< FONT>Asset>(page_Return);

    NavigationWindow navWin = new NavigationWindow();

    navWin.Navigate(page);

    navWin.ShowDialog();

    }

     

    the nav window with the page function shows up fine, and it breaks at my break point on btnOk_Click just fine, it calls OnReturn() but it never goes into the actual event code here:

    Code Snippet

    void page_Return(object sender, System.Windows.Navigation.ReturnEventArgs<InventoryPlus.Entities.Asset> e)

    {

    AssetEditView view = new AssetEditView();

    view.Asset = e.Result;

    TabItem item = new TabItem();

    item.Content = view;

    item.Name = view.Asset.TagNumber;

    TabHost.Items.Add(item);

    }

     

     examples on the web show OnFinish() but i can't find that method at all.

     

    is OnReturn() the correct method to call when returning from a PageFunction?

    Monday, June 25, 2007 4:49 PM

Answers

  • This is a limitation of the implementation. Only the previous page ("calling page") in the NavigationWindow can handle the Return event. http://msdn2.microsoft.com/en-us/library/ms602911.aspx.

    As a workaround, you can find some other way for your PF to signal to the window that it's done. You can consider even closing the window directly. (It should be accessible via this.Parent.)

    We will be addressing this limitation in a future release.

     

    Monday, June 25, 2007 7:35 PM