COM exception access resource dictionary

5 posts, 1 answers
  1. Mark
    Mark avatar
    29 posts
    Member since:
    Aug 2010

    Posted 17 May 2012 Link to this post

       We're using the following code snippet to get the buttons etc on the map as per previous advice from Telerik.
    On migrating from SL4 2012.1.215 to 2012.1.326 release the first line throws a COM exception.
    
    I have tried referencing in the Office_Black.dll with no success.
    
    var innerResourceDictionary = new ResourceDictionary
    {
        Source = new Uri("/Telerik.Windows.Controls.DataVisualization;component/Themes/Map/OfficeBlack/Styles.xaml"UriKind.Relative)
    };
    var dataTemplate = innerResourceDictionary["MapSourceButton"as DataTemplate;
     
    this.RegisterSetSourceCommand(typeof(RoadModeMapProvider), "Road", dataTemplate, new Uri("/Telerik.Windows.Controls.DataVisualization;component/themes/map/road.png"UriKind.RelativeOrAbsolute), nullnull);
    this.RegisterSetSourceCommand(typeof(ArialModeMapProvider), "Arial", dataTemplate, new Uri("/Telerik.Windows.Controls.DataVisualization;component/themes/map/aerial.png"UriKind.RelativeOrAbsolute), nullnull);
    
    
    

  2. Mark
    Mark avatar
    29 posts
    Member since:
    Aug 2010

    Posted 20 May 2012 Link to this post

    bump

    nothing on what the Uri should be with the latest version of the code?

    new Uri("/Telerik.Windows.Controls.DataVisualization;component/Themes/Map/OfficeBlack/Styles.xaml", UriKind.Relative) <-- this throws the exception

  3. DevCraft banner
  4. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 22 May 2012 Link to this post

    Hello Liam,

    Actually it is not a good idea to use internal control's resources (like templates and styles) in the application directly, because they can be changed, renamed or removed at any time. The 'MapSourceButton' data template doesn't exist as separate resource in the RadMap resource dictionary anymore. It was removed because of the changes in the RadMap styling and templating.
    Currently the map source button uses default template if it is not specified (null). So, you can just not use ResourceDictionary and you can use a code like the following:
    this.RegisterSetSourceCommand(typeof(RoadModeMapProvider), "Road", null, new Uri("/Telerik.Windows.Controls.DataVisualization;component/themes/map/road.png", UriKind.RelativeOrAbsolute), null, null);
    this.RegisterSetSourceCommand(typeof(ArialModeMapProvider), "Arial", null, new Uri("/Telerik.Windows.Controls.DataVisualization;component/themes/map/aerial.png", UriKind.RelativeOrAbsolute), null, null);

    Regards,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Mark
    Mark avatar
    29 posts
    Member since:
    Aug 2010

    Posted 22 May 2012 Link to this post

    I was only using the resource as per advice and suggestions from Telerik.

    We ended up going with something fairly similar to what you suggested, removing all references to Uri's

    this.RegisterSetSourceCommand(typeof(RoadModeMapProvider), "Road", null, null, null, null);
    this.RegisterSetSourceCommand(typeof(ArialModeMapProvider), "Arial", null, null, null, null);

    the road.png and arial.png Uri were not resolving anyway - so all we're missing is some fancy icons

    to note: the new version of the map controls seems to perform much better than previous versions
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 25 May 2012 Link to this post

    Hi Liam,

    Sometimes we should make breaking changes to improve our control for different purposes (performance, usability, implementation new features which appear in .net framework and silverlight like inline styling and so on). So, in some cases inner resources could be changed from one version to next.

    In fact these png-files are used for Bing Maps provider which currently is our primary map provider. So, I think you can use them as a 'stable' resource.
    I'm sorry for incorrect Uri to them in previous post. It seems it was a 'copy-paste' mistake. Currently these images are placed in the /Telerik.Windows.Controls.DataVisualization;component/themes/ path. So, you can use them like this:

    this.RegisterSetSourceCommand(typeof(RoadModeMapProvider), "Road", null, new Uri("/Telerik.Windows.Controls.DataVisualization;component/themes/road.png", UriKind.RelativeOrAbsolute), null, null);
    this.RegisterSetSourceCommand(typeof(ArialModeMapProvider), "Arial", null, new Uri("/Telerik.Windows.Controls.DataVisualization;component/themes/aerial.png", UriKind.RelativeOrAbsolute), null, null);

    Greetings,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner