Add an image in a WPF button

前端 未结 7 979
执念已碎
执念已碎 2020-12-23 12:59

I tried this solution:

7条回答
  •  忘掉有多难
    2020-12-23 13:59

    In the case of a 'missing' image there are several things to consider:

    1. When XAML can't locate a resource it might ignore it (when it won't throw a XamlParseException)

    2. The resource must be properly added and defined:

      • Make sure it exists in your project where expected.

      • Make sure it is built with your project as a resource.

        (Right click → Properties → BuildAction='Resource')

    Snippet

    Another thing to try in similar cases, which is also useful for reusing of the image (or any other resource):

    Define your image as a resource in your XAML:

    
         
    
    

    And later use it in your desired control(s):

提交回复
热议问题