在画布中的WPF中在画布上拖动dynamica控件,而不在其他控件上重叠. [英] dragging dynamica control on canvas in wpf within canvas and not overlapping on other.
本文介绍了在画布中的WPF中在画布上拖动dynamica控件,而不在其他控件上重叠.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我已经引用了代码WPF图表设计器:第1部分
并更新了我的想法,如下所示
Hi Friends,
i have referred code WPF Diagram Designer: Part 1
and updated with my idea as follows
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.
推荐答案
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
System.Windows.Shapes.Ellipse lb =新的System.Windows.Shapes.Ellipse();
lb.IsHitTestVisible = false;
lb.Name ="dynecp";
lb.Fill = System.Windows.Media.Brushes.DeepSkyBlue;
System.Windows.Controls.ContentControl contcrl =新的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"]作为ControlTemplate;
contcrl.ApplyTemplate();
tes1t.Children.Add(contcrl);
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);
这篇关于在画布中的WPF中在画布上拖动dynamica控件,而不在其他控件上重叠.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文