简体   繁体   中英

WP7 how to create a button that change background image when pressed

I see [some questions about how to change button background using Visual State Manager][1]. But what I want is a button that can be used in XAML like this

<Button NormalImage="/image/normal.png" PressedImage="image/pressed.png />

There user can specify 2 images for 2 button states (Normal and Pressed), and when the button is pressed, it uses the PressedImage.

How to do that ?

You would have to make your own user control and have those properties exposed as dependency properties so you are able to bind them.

In you user control, you can use the visual state manager to change the background when click/tap event is received

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM