Is it possible to implement mouse hover selection by hover on the object and drawing a circle and drag selection hover box in WPF. what I want specifically when the user hover on the button a by drawing a circle this button make specific action like as click on it. Could you give a bit of sample code or a link?
Asked
Active
Viewed 1,385 times
1 Answers
2
It is an advanced topic and involves the use of adorners More information can be found here :
and
What's the point to WPF adorners?
A small example where I used it :
public class SelectionAdorner : Adorner
{
public SelectionAdorner(UIElement adornedElement)
: base(adornedElement)
{
}
protected override void OnRender(DrawingContext drawingContext)
{
Rect adornedElementRect = new Rect(0,0,ActualWidth,ActualHeight);
// Some arbitrary drawing implements.
SolidColorBrush renderBrush = new SolidColorBrush(Colors.Green);
renderBrush.Opacity = 0.2;
Pen renderPen = new Pen(new SolidColorBrush(Colors.Navy), 1.5);
double renderRadius = 5.0;
// Draw a circle at each corner.
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopLeft, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopRight, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomLeft, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomRight, renderRadius, renderRadius);
}
}

Community
- 1
- 1

Philip Stuyck
- 7,344
- 3
- 28
- 39
-
Can i define specific action when the mouse hover on the button without click it ! – mbugr Mar 17 '15 at 19:49
-
You control how and when to adorn. Mouse movement is anyway something your adorner is required to catch. – Philip Stuyck Mar 17 '15 at 19:52
-
I said it is an advanced topic. start reading the first link in this answer. – Philip Stuyck Mar 17 '15 at 21:28
-
it is the answer to your question, I cannot help it if the topic is complex. – Philip Stuyck Mar 20 '15 at 20:38