windows store app binding Button background to an image RRS feed

  • Question

  • Hello,

    My App using C# needs to dynamically create a bunch of clickable images.

    I tried:

    <Button Content="" Margin="20,0" Width="40" Height="30">
                                        <ImageBrush ImageSource="{Binding Image}" Stretch="None"/>

    But didn't work.

    I tried some static string as <ImageBrush ImageSource="ms-appx:///Images/test.png" />, but didn't work either.

    How to make it work? Thanks.

    Wednesday, August 7, 2013 12:21 AM


All replies

  • Your XAML looks good, can you share the value of the Image string (the value you are binding the ImageSource to)? Also try <ImageBrush ImageSource="Images/test.png"/> and see if that works.

    Good luck,


    Wednesday, August 7, 2013 4:57 AM
  • Hi,Chunmiao

    I do not know what the specific value in your image.So I try set imageSource in XAML,I try like this:

    <Button Height="51" Margin="0,375,0,342" Width="68">
                    <ImageBrush ImageSource="ms-appx:///Assets/Logo.png"></ImageBrush>

    I found that code work ok.

    ms-appx  is used to refer to app files that come from the app's package. So,you can make sure what the specific position does the test.png exist.Then I recomment you can see this link to know kind of Uri schemes and how to set image source:



    If there is something unclear, we are willing to help!

    Best Wishes!

    • Marked as answer by Chunmiao Wednesday, August 7, 2013 9:10 PM
    Wednesday, August 7, 2013 1:37 PM
  • Thanks you so much!

    I must have a typo or something, the image is showing indeed.

    Wednesday, August 7, 2013 9:09 PM