I'm trying to add a toolbar to the viewer - to implement zoom previous and zoom next functionality. (if there is a better way please let me know) I'm currently trying to convert the esri Silverlight ToolBarWidget example to an add-in. The problem I'm having is trying to handle the Map.ExtentChanged Event. I am trying to implement this in the code behind. When I debug it throws this error: XamlParseException ... InnerException: Use the "new" keyword to create an object instance. InnerException: Check to determine if the object is null before calling the method. Any help / suggestions would be great. Thank you.
public PrevNextToolbar()
{
InitializeComponent();
MyDrawObject = new Draw(MapApplication.Current.Map)
{
FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol,
DrawMode = DrawMode.Rectangle
};
MapApplication.Current.Map.ExtentChanged += new EventHandler<ExtentEventArgs>(Map_ExtentChanged);
MyDrawObject.DrawComplete += myDrawObject_DrawComplete;
}
private void Map_ExtentChanged(object sender, ExtentEventArgs e)
{
if (e.OldExtent == null)
{
_extentHistory.Add(e.NewExtent.Clone());
return;
}
if (_newExtent)
{
_currentExtentIndex++;
if (_extentHistory.Count - _currentExtentIndex > 0)
_extentHistory.RemoveRange(_currentExtentIndex, (_extentHistory.Count - _currentExtentIndex));
if (_nextExtentImage.IsHitTestVisible == true)
{
_nextExtentImage.Opacity = 0.3;
_nextExtentImage.IsHitTestVisible = false;
}
_extentHistory.Add(e.NewExtent.Clone());
if (_previousExtentImage.IsHitTestVisible == false)
{
_previousExtentImage.Opacity = 1;
_previousExtentImage.IsHitTestVisible = true;
}
}
else
{
MapApplication.Current.Map.IsHitTestVisible = true;
_newExtent = true;
}
}