How to change\set background image of a button in C# WPF code?

后端 未结 3 1935
陌清茗
陌清茗 2020-12-05 20:54

I\'m trying to change background image of my button to some other image and I encountered some errors. This is the code I have on my xaml:

    
3条回答
  •  情深已故
    2020-12-05 21:22

    If it is not included, include the file "Image\Logo.png" in the project. Then set it's build action to "Resource" by visiting the properties tab for that file (right-click).

    Setting action to build resource

    Also, I'm not sure what you're trying to do in the Click handler of the button. You are already setting the background image in the XAML. Unless you are setting it to another image in the Click handler, that code is not needed.

提交回复
热议问题