views:

112

answers:

2

My aim is to get fine control "animation" when it is mouse-over-ed. For example, I have a "map" of controls (game map that represent different type of terrain), each of them is an image with trees/rocks/hills on the green grass or water (lake or see) image of blue/cyan color. When user point any image with mouse it should get shiny: either get more bright background or get a shiny border.

It is hard to say what exactly I want to have (either background change or border), I would like to try each of them and see what is the most appropriate for me.

I am going to have a custom control (MapTile) that will represent a map tile. I know how to catch MouseEnter/MouseLeave events, but not sure how to change control style and if it is a good idea to work with control style in CodeBehind, probably there are better XAML-based solutions.

Could you please help with a solution that provide few goals: Goal1: Add highlighted border around the control (it will be squares/rectangles, or circles; use what is easier) on mouse enter, remove border on move leave; Goal2: Change some properties of my CustomControl (for example, background color).

Thank you very much! 1. How to han

A: 

You might find it easiest to get hold of Expression Blend and use it to create a custom template for your control.

The Learn Expression Blend page would be a good place to start. Look for tutorials on customising buttons and this is the same sort of thing that you want to do.

ChrisF
It is not a problem to create a control. Problem is to handle events and change control's style. I just don't know how to do that and can't find workable example.
Budda
@Budda - Don't any of the tutorials cover that aspect? I have seen at least one that does, but can't find it at the moment.
ChrisF
I saw few examples on WPF that uses triggers (which are not supportable by Silverlight). Trying to find something for Silverlight - didn't find anything for my case. I saw examples for Listboxes, etc... I could handle mouse events in code-behind and change/create controls... but guess it should be more proper way
Budda
Get Expression Blend, tried to create few primitive controls... but how to work with him to get events handling... don't have any idea. ChtrisF, could you please point me to some kind of tutorial (if possible linked to required topic)?
Budda
found something useful, will try to implement (but I see, expression blend IS VERY BIG area for examination).
Budda
@Budda - sorry I couldn't be more specific. I did find a tutorial about a year ago, but stupidly didn't keep a reference to the website.
ChrisF
A: 

You need to use an attached behavior on your control. You don't need to learn Blend for this.

Check this one as an example, but you can search the site for Mouse Over for other examples.

http://gallery.expression.microsoft.com/en-us/MouseOver3D

kmacmahon