public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if (this.Layer != null && bigMap != null)
{
bigMap.Layers.Remove(this.Layer);
}
bigMap = GetTemplateChild("bigMap") as Map;
if (bigMap == null)
{
throw new ArgumentNullException(Properties.Resources.MagnifyingGlass_BigMapNotFoundInTemplate);
}
bigMap.Layers.LayersInitialized += Layers_LayersInitialized;
if(Layer != null)
bigMap.Layers.Add(Layer);
bigMap.MinimumResolution = double.Epsilon;
bigMap.MaximumResolution = double.MaxValue;
this.MouseLeftButtonDown += MagnifyBox_MouseLeftButtonDown;
this.MouseMove += MagnifyBox_MouseMove;
this.MouseLeftButtonUp += MagnifyBox_MouseLeftButtonUp;
this.Opacity = 1;
if ((this.Visibility == Visibility.Visible) && Map != null)
{
Dispatcher.BeginInvoke((Action)delegate()
{
SetMagnifyResolution();
UpdateMagnifyMapCenter();
});
}
}