Irregular PNG button's click event in WPF

前端 未结 2 1442
长情又很酷
长情又很酷 2021-01-02 19:29

I need an irregularly shaped button in WPF. I am doing it in this way using XAML:

2条回答
  •  春和景丽
    2021-01-02 20:19

    Michal, I wouldn't create a real "button". Just go to blend, get your image as an image brush into a rectangle, right-click make it a Button. If you are using Blend 4, this will generate the appropriate states in the Visual State Manager. You can get your mouse over, pressed, etc., to look like a button. Even disabled state.

    Here's an example:

    
            
        
    

    Now use the button as follows:

    I know this is not using the transparent png as the button but it would be a much better alternative if you have the ability to convert the png to xaml.

提交回复
热议问题