Image binding to resource image, wrong size RRS feed

  • Question

  • Hello,
    I have a problem with binding to a resource image.
    I have an image defined in xaml like this:
    <Image HorizontalAlignment="Center" Source="{Binding ElementName=WindowControl, Path=ImagePath}"/>
    the imagePath is a string, that changes from time to time and looks like this: ImagePath = "\Images\testImage.png"
    While he does always load the correct image, it uses always an extremely huge size, not the original of the image.
    The images range from 50x50 to 300x100
    When binding however, the width is always like 1500 (dual monitor) and the height respectively.
    Why doesn't the image use the original height?
    Or how could I read the original size from the resource image and then set it myself everytime?

    Sunday, August 2, 2009 11:15 AM


  • Solved itself.
    I had had the image in a grid and the width setting of the columnDefinition caused that strange behavior, by setting it to Auto, the image is sized correctly. *strange*
    • Marked as answer by salat88 Sunday, August 2, 2009 1:52 PM
    Sunday, August 2, 2009 1:52 PM