xaml - Show border control on hover -


i new xaml , programming in windows store applications, please bare me =)

i've got border control, holds image control. basicly want show border control if image control hovered. similar css :hover effect.

whats easiest way achieve this?

there so many ways achieve this, , depends on setup is.

  • is 1 isolated image, or want able reuse functionality elsewhere?
  • is image inside datatemplate listview or other items control?
  • would ok writing code-behind achieve this, or preferably xaml-only solution? (hopefully latter.)
  • etc.

if it's 1 image, handle pointerentered , pointerexited events on image control set border's borderbrush color yellow (for example) , transparent, respectively. since said you're new xaml, "easiest" solution can offer. maybe else can suggest other simple alternatives. unfortunately, there no ":hover"-like styling out of box. have write functionality yourself.


my preferred solution bundle functionality kind of reusable component. solutions come mind:

  1. create usercontrol housing border , image necessary code-behind handle pointer enter , exit events.
  2. create new templated contentcontrol, allowing set arbitrary uielement inside border. allows use templatebindings set things borderbrush outside template.
  3. create behavior (blend sdk) can attached border houses necessary logic.

on topic of blend sdk, solutions 1 , 2 can achieved 0 code-behind if make use of visualstates , blend's eventtriggerbehavior , gotostateaction handle changing visual states on pointerentered , pointerexited events.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -