locked
Image shows during design time but not during runtime RRS feed

  • Question

  • I am pretty new to wpf and had to look up exactly how to use resources. I am trying to display our company's logo on a window which correctly shows in xaml/design time but does not show on runtime no matter if its set to resource, embedded resource, content, copy always, or do not copy. These are the two lines of code I have tried and again both work in design time but not run time.

    <Image Grid.Column="3" Margin="2" Source ="/AMS_WPF;component/logo.png"
                   ></Image>
    
    and the second line is 
    
    <Image Grid.Column="3" Margin="2" Source ="pack://application:,,,/Resources/logo.png"
                   ></Image>
    

    The way I added the resource image to my project resource folder is by going to the project properties>resources>add existing resource and browsing to it

    Tuesday, March 26, 2013 4:05 AM

Answers

  • Hi MARV102,

    >>The way I added the resource image to my project resource folder is by going to the project properties>resources>add existing resource and browsing to it

    Adding resource by this way, VS will create a folder which named"Resources" by default. You can find this image below this folder.

    So, the  xaml code need changed to:

    <Image Grid.Column="3" Margin="2" Source ="Resources/logo.png" ></Image>

    You need also change the image's Properties: Build Action :Content ; Copy to Output Directory:Copy if newer.

    Regards,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by MARV102 Wednesday, March 27, 2013 4:36 PM
    Wednesday, March 27, 2013 3:07 AM