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 7779405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:38:12+00:00 2026-06-01T18:38:12+00:00

I’m trying to allow for multiple icon sizes depending on certain conditions. To do

  • 0

I’m trying to allow for multiple icon sizes depending on certain conditions. To do this, I have a bunch folders: ‘Images\Icons\…\*.png’ where the … is the size (16, 32, 64, 128, 256, etc.) Each folder contains all the icons optimized for the given size.

My problem I can’t seem to specify a folder in the image source path… i.e.:

<Image x:Name  = "img" 
       Stretch = "None" 
       Source  = "{Binding StringFormat=Images\Icons\{0}\Multi.png, 
                   RelativeSource={RelativeSource Self}, 
                   Path=Parent.Parent.Tag}" />

For now, I’m just storing the folder name in the grandparent’s tag (I will be binding to something else in the future, but right now I’m just trying to piece this bit together). When I try to build the above xaml, I get an error:

The text \Multi.png ... is not allowed after the closing } of a markup extension.

This leads me to beleave that it’s seeing the {0} as a markup extension instead of it being a part of my string format. I’ve read about escaping with {} and using single quotes to specify the string format, but neither works:

Source  = "{Binding StringFormat={}Images\Icons\{0}\Multi.png, ...

The above returns the same error as when I don’t escape at all..

Source  = "{Binding StringFormat='Images\Icons\{0}\Multi.png', ...

Source  = "{Binding StringFormat='{}Images\Icons\{0}\Multi.png', ...

The above two prevents the error from occurring, but results in the image source being null.

Does anyone know how to acheive this?

(Just to clarify, if the grandparent’s tag is set to ’16’, then I want the image source bound to Images\Icons\16\Multi.png … If the tag is set to ’32’ then I need to bind the source to Images\Icons\32\Multi.png. As a test, I set the grandparents tag to the full path, and excluded the stringformat. The relative binding to the grandparents tag succeeded and the image was shown. It only fails when I try to specify just the folder name with a stringformat to specify the rest of the path).

  • 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-06-01T18:38:13+00:00Added an answer on June 1, 2026 at 6:38 pm

    The StringFormatter attribute of Binding will only work if the target is of type String. Otherwise, it will simply be ignored.

    You can fix this by adding a converter to your binding, which takes the format string and your tag, applies the formatting, and converts it to an ImageSource. In C#, your converter will look something like:

    public sealed class ImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            if (parameter == null || parameter.Equals(String.Empty)) parameter = "{0}";
            string path = String.Format((string) parameter, value);
            return new BitmapImage(new Uri(path));
        }
    
        public object ConvertBack(object value, Type targetType,
                                  object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    Once you’ve got your converter, you can add the following to your Resources in XAML:

    <local:ImageConverter x:Key="ImageConverter" />
    

    And modify your Source binding to:

    <Image x:Name="img"
           Stretch="None"
           Source="{Binding Parent.Parent.Tag, Converter={StaticResource ImageConverter}, 
                            ConverterParameter='Images\\Icons\\{0}\\Multi.png', 
                            RelativeSource ={RelativeSource Mode=Self}}" 
    />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to loop through a bunch of documents I have to put
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.