Click here to Skip to main content
15,900,675 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

i have referred code WPF Diagram Designer: Part 1

and updated with my idea as follows
C#
private void button1_Click(object sender, RoutedEventArgs e)
       {
           System.Windows.Shapes.Ellipse lb = new System.Windows.Shapes.Ellipse();
           lb.IsHitTestVisible = false;
           lb.Name = "dynecp";
           lb.Fill = System.Windows.Media.Brushes.DeepSkyBlue;

           System.Windows.Controls.ContentControl contcrl = new System.Windows.Controls.ContentControl();
           contcrl.MinHeight = 35;
           contcrl.MinWidth = 90;
           contcrl.Height = 40;
           contcrl.Width = 120;
           contcrl.Content = lb;
           contcrl.Name = "iamdyn";

           contcrl.Template = this.Resources["DesignerItemTemplate"] as ControlTemplate;
           contcrl.ApplyTemplate();
           contcrl.Margin = new System.Windows.Thickness(10, 10, 0, 0);

           DesignerCanvas.Children.Add(contcrl);
       }


here i am able to take control on canvas which resizes but not not moving around.

could someone please help ??

thank you.
Posted

C#
System.Windows.Shapes.Ellipse lb = new System.Windows.Shapes.Ellipse();
            lb.IsHitTestVisible = false;
            lb.Name = "dynecp";
            lb.Fill = System.Windows.Media.Brushes.DeepSkyBlue;
            
            System.Windows.Controls.ContentControl contcrl = new System.Windows.Controls.ContentControl();
            contcrl.MinHeight = 35;
            contcrl.MinWidth = 90;
            contcrl.Height = 40;
            contcrl.Width = 120;
            contcrl.Content = lb;
            contcrl.Name = "iamdyn";
         
            Canvas.SetLeft(contcrl, 30);
            Canvas.SetTop(contcrl, 40);
            contcrl.Template = this.Resources["DesignerItemTemplate"] as ControlTemplate;
            contcrl.ApplyTemplate();
            tes1t.Children.Add(contcrl);



Thanks for looking into problem.

problem solved finally
 
Share this answer
 
System.Windows.Shapes.Ellipse lb = new System.Windows.Shapes.Ellipse();
lb.IsHitTestVisible = false;
lb.Name = "dynecp";
lb.Fill = System.Windows.Media.Brushes.DeepSkyBlue;

System.Windows.Controls.ContentControl contcrl = new System.Windows.Controls.ContentControl();
contcrl.MinHeight = 35;
contcrl.MinWidth = 90;
contcrl.Height = 40;
contcrl.Width = 120;
contcrl.Content = lb;
contcrl.Name = "iamdyn";

Canvas.SetLeft(contcrl, 30);
Canvas.SetTop(contcrl, 40);
contcrl.Template = this.Resources["DesignerItemTemplate"] as ControlTemplate;
contcrl.ApplyTemplate();
tes1t.Children.Add(contcrl);
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900