ThinkGeo.com    |     Documentation    |     Premium Support

Style problem in version 6

 I was using below style on version before version 6 without any problem


 



           TargetType="{x:Type map:WpfMap}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type map:WpfMap}">
                        <Grid>
                                                            Background="{TemplateBinding Background}">
                                                                    Background="Transparent">
                                    <Canvas x:Name="OverlayCanvas">
                                        <Canvas.Resources>
                                            <Storyboard x:Key="ZoomStoryboard"
                                                    Duration="0:0:0.45">
                                                <DoubleAnimation Duration="0:0:0.35"
                                                             Storyboard.TargetName="ZoomTransform"
                                                             Storyboard.TargetProperty="ScaleX" />
                                                <DoubleAnimation Duration="0:0:0.35"
                                                             Storyboard.TargetName="ZoomTransform"
                                                             Storyboard.TargetProperty="ScaleY" />
                                            </Storyboard>
                                        
                                        <Canvas.RenderTransform>
                                            <ScaleTransform x:Name="ZoomTransform" />
                                        
                                    </Canvas>
                                </Canvas>
                                <Grid x:Name="ToolsGrid" />
                            </Canvas>
                            <StackPanel HorizontalAlignment="Left"
                                    VerticalAlignment="Bottom"
                                    Margin="5">
                                <Button Height="25" Width="100" />
                            </StackPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


<map:WpfMap x:Name="Map1" Style="{StaticResource MapControlStyle}"></map:WpfMap>
 

 


 but on version 6 , I am receiving 'Object reference not set to an instance of an object.' 
and this is StackTrace:     

 



at ThinkGeo.MapSuite.WpfDesktopEdition.WpfMap.OnApplyTemplate()    at System.Windows.FrameworkElement.ApplyTemplate()    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at System.Windows.Controls.Grid.MeasureOverride(Size constraint)    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at System.Windows.Controls.Border.MeasureOverride(Size constraint)    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at System.Windows.Controls.Grid.MeasureOverride(Size constraint)    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at System.Windows.Controls.Grid.MeasureOverride(Size constraint)    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)    at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at System.Windows.Controls.Border.MeasureOverride(Size constraint)    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at System.Windows.Window.MeasureOverrideHelper(Size constraint)    at System.Windows.Window.MeasureOverride(Size availableSize)    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)    at System.Windows.UIElement.Measure(Size availableSize)    at System.Windows.Interop.HwndSource.SetLayoutSize()    at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)    at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)    at System.Windows.Window.SetRootVisual()    at System.Windows.Window.SetRootVisualAndUpdateSTC()    at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)    at System.Windows.Window.CreateSourceWindow(Boolean duringShow)    at System.Windows.Window.CreateSourceWindowDuringShow()    at System.Windows.Window.SafeCreateWindowDuringShow()    at System.Windows.Window.ShowHelper(Object booleanBox)    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)    at System.Windows.Threading.DispatcherOperation.InvokeImpl()    at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    at System.Windows.Threading.DispatcherOperation.Invoke()    at System.Windows.Threading.Dispatcher.ProcessQueue()    at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)    at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)    at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)    at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)    at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)    at System.Windows.Threading.Dispatcher.Run()    at System.Windows.Application.RunDispatcher(Object ignore)    at System.Windows.Application.RunInternal(Window window)    at System.Windows.Application.Run(Window window)    at System.Windows.Application.Run()    at DisplayIsoLinesWPF.App.Main() in c:\Users\Ben.BEN-LAPTOP\Desktop\Sample_Isolines\DisplayIsoLinesWPF\obj\x86\Debug\App.g.cs:line 0    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    at System.Threading.ThreadHelper.ThreadStart()



Hi Ben, 
  
 I tested with you code but cannot get the exception, could you please send your sample to us to have a test? 
  
 Thanks, 
  
 Edgar

 Hi,


 


I attached sample eith Style problem for you.


I don't know this will help you or not, when I'm using version 6.x (even without Style) in the design mode It doesn't show the control.


'Error 1 The name "WpfMap" does not exist in the namespace "clr-namespace:ThinkGeo.MapSuite.WpfDesktopEdition;assembly=WpfDesktopEdition".


but when I'm running the application, it's work fine(obviously without Styling).


Regards,


Ben


 


 

 



StyleIssue.zip (391 KB)

Ben,


Attached is the sample.xaml code I modified, please get it and replace the code with yours.



Hope it helps,


Edgar



sample.xaml.txt (13.5 KB)

Thanks Edgar, 
  
 It’s working now, just can you please say why we need that ‘Term of use’ for Style to work? 
  
 Regards, 
 Ben

Because we just want to display one BingMaps Logo and license on the map even it's multi-tile mode, it'll be enabled when using bing maps, our development team is still working on it to find a better way to display it, maybe it'll be not necessary in the coming days. 



Regards, 



Edgar



Hi Edgar, 
  
 I found another issue with Style, if you style the map then the SimpleMarkerOverlay will not work. 
  
 Regards, 
 Ben

Hello Ben, 
  
 Thanks for your further information, we will check this part and make sure it will be fine. 
  
 As soon as we finished this, we will post in the forums. 
  
 Regards, 
  
 Gary