I want to do this:
https://github.com/rails/rails/commit/f50aeda2f73b47c47664e3651c638ba624418b8b
See how, as your mouse cursor moves over the lines of source code, an image/button appears to the left of the table? That.
So I have a Grid, and RowDefinition has MouseEnter and MouseLeave events. Turns out these events are useless and can never fire (please correct me if I’m wrong here), because they require a Background property (even if it’s Transparent), and RowDefinition doesn’t have a Background property.
I can’t just hook MouseEnter on every element in every cell, because by the time I’ve moved my mouse the newly visible button will have already disappeared.
How can I get this working?
The
RowDefinitionsandColumnDefinitionsaren’t actually in the Visual Tree since they areFrameworkContentElements(rather thanFrameworkElements) and that’s why they don’t raise any mouse events, they aren’tVisuals. They are just used by theGridto position its childs.One approach that comes to mind is to use the Attached Events
Mouse.MouseMoveandMouse.MouseLeaveon theGridto get notified when these events are raised for any child in theGridor theGriditself.In the
Mouse.MouseMoveevent handler we can get the relative mouse position to theGridand calculate whichRowDefinitionis currently being hoovered by the mouse and store that in an Attached Property, likeMouseOverRowDefinition.Now we can query the
Gridfor theMouseOverRowDefinitionso the rest is just a matter of comparingGrid.Rowfor theImagetoMouseOverRowDefinitionfor theGridto decide if it should beVisibleor not.Uploaded a small sample app that does this here if you want to try it out:
http://dl.dropbox.com/u/39657172/MouseOverGridRowDefinition.zip