Good Day,
I have a Silverlight control that appears on top of another (picture a pop-up box). In this pop-up control, I have a scrollview (height = 250) with a stack panel (instance name = spMain, orientation = vertical) inside. Within the contents of the stack panel are several textboxes stacked on top of each other. When I tab from textbox to textbox, the scrollviewer automatically moves toward the bottom (I wrote code in an event handler that all textboxes are linked to that does that).
The problem I'm having is when I attempt to close out the pop-up control, I'm receiving an error stating that the value does not fall within the expected range.
if (sender is TextBox) { TextBox tb = (TextBox)sender; try { // Code bombs out here when I attempt to close out the pop-up control Point pt = tb.TransformToVisual(spMain).Transform(new Point()); if (pt.Y >= scrollViewerHeight - tb.ActualHeight) { svMain.UpdateLayout(); svMain.ScrollToVerticalOffset(scrollViewerHeight += pt.Y); } } catch (ArgumentException aex) { // Don't want to eat the exception string errorMessage = aex.Message; System.Diagnostics.Debug.WriteLine(errorMessage); } }
I'm not surprised I'm getting the error, because it appears to make sense, but what I'm looking for is some sort of User Control Unloaded event or prevent the offending code from executing.
Does anyone have any ideas on how to go about this?
TIA,
coson