我正在尝试实现在运行时制作的布局。
布局将分为2,3,4,......
例如,有一个带有1张图像的Big Box。
如果我拖放图像,它将被分成两部分。
赞A => A | B or B | A
如果我拖放另一张图片,它将是
A | | B
A | B => --| B or A | --
C | | C
简单的提示会很棒。
答案 0 :(得分:1)
这个想法到目前为止很简单。让我们说清楚。首先,根堆栈面板让我们说它是A,将是Orientation="Horizontal"
如下所示:
StackPanel A = new StackPanel();
A.Width = 300;
A.Height = 200;
A.Background = new SolidColorBrush(Colors.LightBlue);
A.Orientation = Orientation.Horizontal;
现在,一旦我们拥有A,我们知道它是根,每当我们添加一些东西时,它就会将它放在右边,这就像你想要的那样A | B或更多A | B | C。 现在,拖放图像检查 -
图像的坐标,用于检测它悬停在哪个父布局上,然后检查它是否为StackPanel(if(theLayout is StackPanel)
)
现在检查stackpanel的方向。 [PseudoCode]
-
if(Horizontal)
{
//Create a stackpanel with Vertical Orientation and place the image inside it
//stackpanel_with_v_orientation.Children.Add(yourImage)
//then add this stackpanel to theLayout like theLayout.Children.Add(stackpanel_with_v_orientation);
}
else
{
//its over some sub panels,which are ofcourse with vertical
//orientation.just add this up.
}
这样的事情!让我知道它是否有意义。
答案 1 :(得分:0)
答案 2 :(得分:0)
最后你想要一个这样的对接控件:http://avalondock.codeplex.com/
答案 3 :(得分:-1)
Panel
实现。在此Panel
中,您可以访问Panel
中的子项(项目),因此应能够通过一些仔细的思考来实现您的要求。我可以为你提供一些关于这个主题的教程的链接,但在那之后,你几乎都是你自己的。
请查看这些链接中的文章以获取帮助: