在点击位置wpf处在网格中添加网格

时间:2014-11-29 05:39:20

标签: wpf vb.net wpf-graphics

我想在点击位置的网格中添加网格。该网格具有usercontrol作为其内容。在主网格中的点击事件中,我通过以下代码得到关于该网格的信息:

Dim mousePositin As Point 
mousePosition = Mouse.GetPosition(gridFloorPlans)

之后我通过以下代码添加了子网格:

Dim UC As New UserControl1
Dim gr As New Grid

gr.Children.Add(UC)
gr.Height = 31
gr.Width = 31

Dim thick As New Thickness
thick.Left = mousePosition.X
thick.Top = mousePosition.Y
gr.Margin = thick

gridFloorPlans.Children.Add(gr)

问题是这个网格被添加但不是在远离该位置的那个位置上。 有什么问题?我怎么能正确地做到这一点?

0 个答案:

没有答案