Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF
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 ;//Contiene al circulo pequeño
        Canvas CnvCirculoG; // Contiene al circulo grande

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.
Posted 19-Dec-12 12:47pm
(unknown member)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 295
2 Sergey Alexandrovich Kryukov 207
3 Peter Leow 155
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 7,460
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 19 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100