Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6153895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:10:10+00:00 2026-05-23T20:10:10+00:00

I have several resources declared in XAML markup and would like to access the

  • 0

I have several resources declared in XAML markup and would like to access the resources in my view model. I could easily use something foo.Resources["resourceKey"] or findResource("") but that would mean that I would have to couple my XAML and C# code closely together. Not what I intended to do when I started using MVVM.

Is there a best practice or any way to use resources defined in the view in the view model?

Update:

The resources are mainly symbol definitions which are used to define the appearance of symbols in ESRI maps.
For example this:

<esri:MarkerSymbol x:Key="SMS">
    <esri:MarkerSymbol.ControlTemplate>
        <ControlTemplate>
            <Ellipse x:Name="Element" Margin="-7,-7,0,0" Width="14" Height="14" Fill="Blue">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="SelectionStates">
                        <VisualState x:Name="Unselected" />
                        <VisualState x:Name="Selected">
                            <Storyboard>
                                <ColorAnimation Storyboard.TargetName="Element" Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)" To="Green" Duration="00:00:0.25"/>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
            </Ellipse>
        </ControlTemplate>
    </esri:MarkerSymbol.ControlTemplate>
</esri:MarkerSymbol>

The symbols are added programatically to the map, though I need to access them in my view model.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:10:11+00:00Added an answer on May 23, 2026 at 8:10 pm

    If you really want to access styles/templates from the view-model layer, one thing you can do is to put the styles in a separate ResourceDictionary (let’s suppose you called it SymbolTemplates.xaml) and load that in:

    var resourceDictionary = new ResourceDictionary()
    {
        Source = new Uri("SymbolTemplates.xaml", UriKind.Relative)
    };
    
    ControlTemplate template = resourceDictionary["SMS"] as ControlTemplate;
    

    (I found that this approach works best if you set the Build Action for SymbolTemplates.xaml to Content.)

    A more MVVM-ish approach would be to have the view-model layer expose the ‘type’ of each symbol. This type would determine the template or style to apply to each symbol added to the view. You’d then use an IValueConverter to convert the type of symbol into the style or template to apply. This value-converter would need to load the resource dictionary, but since value converters live in the view-layer, that doesn’t break MVVM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several old 3.5in floppy disks that I would like to backup. My
I have several icons which are declared in Window.Resources. They show up fine the
In my application I do have several different string resources each per locale like:
Could someone explain how I should use resource injection when I have several packages
I have several resources that I'd like to expose using the WCF Web API.
I have several web applications in production that utilize NFS mounts to share resources
Let's say we have a grails web application exposing several resources. tags urls users
We have several jobs that run concurrently that have to use the same config
I have image files in a directory which have downloaded from several resources. If
We have several fairly large JavaScript files embedded into a single script resources DLL.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.