Hello friends, good afternoon, look I have a user control in which I add two circles from code (emulating a Dial) that look like this:
public partial class KnobControl : UserControl
{
Canvas CnvCirculoP ;
Canvas CnvCirculoG;
public KnobControl()
{
InitializeComponent();
CnvCirculoP.MouseMove += new MouseEventHandler(CircularIndicator_MouseMove);
CnvCirculoP.MouseLeftButtonDown += new MouseButtonEventHandler(CircularIndicator_MouseLeftButtonDown);
CnvCirculoP.MouseLeftButtonUp += new MouseButtonEventHandler(CircularIndicator_MouseLeftButtonUp);
Dibujar ();
}
private void Dibujar()
{
.
.
.
LayoutGrid.Children.Add(CnvCirculoG);
LayoutGrid.Children.Add(CnvCirculoP);
}
The events are as follows:
void CircularIndicator_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
this.isKnobRotating = false;
}
void CircularIndicator_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.isKnobRotating = true;
}
void CircularIndicator_MouseMove(object sender, MouseEventArgs e)
{
if (this.isKnobRotating == true)
{
Point p = new Point(e.GetPosition(this).X, e.GetPosition(this).Y);
int posVal = ObtenerNuevaPosicion(p);
_Value = posVal;
}
}
The problem is that when I use it from the main window and try to drag the small circle, nothing happens ie the "CnvCirculoP", this does not get the focus, how can I fix, please help me.