This is a migrated thread and some comments may be shown as answers.

Frame Navigation and Reentrancy

0 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andy
Top achievements
Rank 1
Andy asked on 13 Apr 2012, 05:00 PM
This is not the perfect place to put this post, but since it's a GridView event I want to catch I thought I would put it here. 
The scenario:

We have an ordering page, which consists of a RadTreeView of the item categories and a RadGridView of the Items and Quantities all sitting in a Splitter.
Items are added to the shopping cart by putting a quantity into a textbox and clicking a button at the top of the Grid. 
We are trapping clicks away from the Grid to see if there are quantities entered that have not been added and then throw a dialog box, like so:

 public void CheckItemQuantities()
 {
  int i = 0;
  bool additems = false;
  if ((ItemListing != null) && (ItemListing.Count > 0))
  {
foreach (ItemOrderDetail iod in ItemListing)
if (iod.Quantity > 0)
 i++;
if (i > 0)
{
additems = System.Windows.Browser.HtmlPage.Window.Confirm(String.Format("You have entered quantities for {0} items that have not been added to your cart. Choose 'OK' to add these items to your cart, 'Cancel' to proceed without those items.", i.ToString()));
if (additems)
 AddToCartPageLevel_Click(this, new RoutedEventArgs());
else
{
 foreach (ItemOrderDetail iod in ItemListing)
  iod.Quantity = 0;
}
}
  }
 }

When the category tree ItemClick fires this code is run and works fine. 
I also want to catch any clicks from outside the frame ('View Cart' for instance) and I was trapping this with the OnNavigatedFrom handler, which working fine with one exception. 

The problem is that there is a multi-function search box outside the frame, that does different searches depending on the Uri of Frame.Content. If there are un-added items on the GridView AND a search is executed from the control outside the Frame a 'reentrancy' error is thrown and the plug-in crashes immediately.

This seems to be because the NavigationFrom and NavigationTo events are piled up, but I do not exactly understand why or what the best solution would be. 

Any pointers?

Thanks,
Andy 
Tags
GridView
Asked by
Andy
Top achievements
Rank 1
Share this question
or