Custom button template in WPF

前端 未结 5 1087
深忆病人
深忆病人 2020-11-29 02:51

I want to create a simple button template with an image and text inside it. But I want to keep the System button\'s look and feel.

How do I create it, step by step?<

5条回答
  •  借酒劲吻你
    2020-11-29 03:08

    If you don't want to write any code-behind, there is another way of doing this (inspired by jeffora's answer). You can use the control's Content field to put the URI to the image you want to see in your button:

    And then you can edit the default Button Style to look like this:

    
    

    The magic is in the 'Source=(Binding ...}' part. It has worked well for me to have the ToolTip there for debugging missing/changed images -- but can easily be removed as well.

提交回复
热议问题