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

  • Home
  • SEARCH
  • 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 424239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:15:36+00:00 2026-05-12T19:15:36+00:00

I’ve got a UserControl that contains a menu. I need to bind the Menu.Icon

  • 0

I’ve got a UserControl that contains a menu. I need to bind the Menu.Icon to a property of the UserControl but it’s not working.

The code starts like this –

        <Border Grid.Row="0">            
        <DockPanel>
            <Image x:Name="testImage" Height="16" Width="16" Source="{Binding ElementName=UC,Path=AddImage}"/>
            <Menu DockPanel.Dock="Left" Height="20"
              VerticalAlignment="Center">
                <MenuItem Header="{Binding ElementName=UC,Path=AddText}">
                    <MenuItem.Icon>
                        <!--<Image x:Name="workswhenin" Height="16" Width="16" Source="pack://application:,,/Kowdox;component/Images/UserIcons/user_add.png"/>-->

                        <Image x:Name="realImage" Height="16" Width="16"
                        Source="{Binding ElementName=UC,Path=AddImage}"/>
                    </MenuItem.Icon>
                </MenuItem>

The first Image you see declared (testImage) works perfectly so I’m happy that the binding is correct. The second Image (commented out and named ‘workswhenin’) contains the pack URI that I’m passing to the UserControls bound property and that works too but the third one (realImage) doesn’t appear at all!

I can’t see ANY reason why it shouldn’t work; i know the binding is good and i know that the image’s placement in the markup is good so what’s going on?

Any help will be greatly appreciated.
Thanks in advance.

  • 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-12T19:15:36+00:00Added an answer on May 12, 2026 at 7:15 pm

    Can’t tell for sure because I can’t see your code behind, but I’m pretty sure I know what the problem is.

    Image.Source expects an object of type ImageSource. When you specify the URL in XAML a default WPF converter is used to convert the URL into an ImageSource object. Because you are using a binding, the default converter is not used. So you are probably trying to set the image source to a URL value instead of an ImageSource object.

    In your code behind property, you will have to create an ImageSource object, which is really a pain. You could create a BitmapImage and pass in the URL.

    The easiest solution is to use Microsoft’s default converter in the code behind property that you are binding to, or use it in the binding explicitly. The converter is called ImageSourceConverter.

    EDIT:

    Here is a simple example:

    Code inside of the binding source:

    public ImageSource AddImageSource
    {
        get
        {
            ImageSourceConverter imgConv = new ImageSourceConverter();
            return imgConv.ConvertFrom(this.AddImage);
        }
    }
    

    Update the bindings to target this property instead of the AddImage property. Make sure you fire the PropertyChanged event for this property also when the AddImage property changes.

    Didn’t take the time to build a test scenario for this, but it should work without any problems.

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

Sidebar

Related Questions

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
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

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.