smohamed
smohamed

Reputation: 3314

button pressed effect when another button is pressed

in my WP7 app using silverlight controls,

I have two buttons, I want to make when I press a button, the other button seems like it's also being pressed (change of color to invert...etc)

something like the native keyboard on wp7 phones when the larger button appear above your thumb

I tried to give both of them the focus, but it's not possible

-Detailed Explanation-

usually, when you press a button, the button style changes according to the theme,

ex: if theme is dark, the button becomes white and the text becomes black. but if the theme is white, the button becomes black when clicked.

My aim is to mimic that behavior to a button when another button is pressed.

Upvotes: 0

Views: 1748

Answers (5)

Saboor Awan
Saboor Awan

Reputation: 1585

try using MS Expression Blend to customize the behavior, details

Upvotes: 0

Emond
Emond

Reputation: 50672

In the click event you could use

VisualStateManager.GoToState(Button1, "Pressed", true);

however to go back to the Normal state you would have to know when the click is over. LeftMouseButtonUp does not work because there is no mouse.

So you could set a timer and revert the state. Ugly but it works.

On a side note: I suspect the design you might want to use a different way of getting the result you need.

Upvotes: 2

SynXsiS
SynXsiS

Reputation: 1898

I haven't done much wp7 development but I believe the normal, active and pressed appearances are implemented as different states of the button and you can programatically set the state. This article should explain it in a bit more detail but the advantage of this approach over manually setting background colours is that it should automatically take advantages of any transitions configured between those states, as well as the black => white, or white => black theme related changes will be done for you too.

http://www.timmykokke.com/2010/11/using-visual-states-in-custom-controls-in-silverlight/

Upvotes: 1

Phil N.
Phil N.

Reputation: 700

In pseudo-code:

Button button1
ToggleButton button2

Button1.MouseDown:
    Set button2 pressed state to true

Button2.MouseUp:
    Set button2 pressed state to false

Upvotes: 0

Brad Boyce
Brad Boyce

Reputation: 1258

Update: In the click handler of one set the background property of the other.

Upvotes: 0

Related Questions