Harry
Harry

Reputation: 3106

Changing VisualStates of a Button in Windows 8/Metro

I have some buttons that I'm changing the ControlTemplates for so I can use Images as the appearance.

I have one image for the normal state and one Image for the PointerOver or Pressed state.

This is where I'm a bit confused: I want this to work on both tablets and desktops. I tried setting the Pressed state but it forces me to double-click on the button to get it to activate. If I set the PointerOver the click works fine; if I set PointerOver and Pressed to the same it works fine. Why is it forcing one click to activate the Pressed state and another click to activate the button Click/Command?

If this is intended, is the idea that I set both PointerOver and Pressed states so it works on desktop? But will this also work on a tablet? I.e., if the user presses a button he/she obviously doesn't have the PointerOver state, so will it not create the scenario I previously described?

Upvotes: 1

Views: 558

Answers (1)

Shawn Kendrot
Shawn Kendrot

Reputation: 12465

If you do not define a state then it assumes that the state is the same as the "normal" state (the default xaml in the template). Setting Pressed and PointerOver do work on a tablet. Most users will not get the PointerOver state, but some tablets have pen support which will show the state when the pen is hovering over the tablet. Some other tablets have sensors and can detect a finger close to the screen. This will also give the PointerOver state.

Upvotes: 1

Related Questions