[英]Dragable shapes in WPF with childs
我的形狀應用程序有問題。 我想要一個可以使架構脫離XML的應用程序。 我的問題是父母的拖拽選項。 因此,例如,我可以有一個帶有兩個矩形的橢圓。 當我拖動父級時,它也必須拖動子級。
我如何設置:
<contentcontrol>
<itemscontrol>
<ellipse>Parent</ellipse>
</itemscontrol>
<itemscontrol>
<rectangle>Child1</rectangle>
</itemscontrol>
<itemscontrol>
<rectangle>Child2</rectangle>
</itemscontrol>
</contentcontrol>
我認為在contentcontrol上不可能有更多的對象。 我的contentcontrol允許拖放,並且像這樣,也可以使用它拖放子項
但是,這是一個問題,當我將其繪制在畫布上時,定位不合適。 因此,借助itemscontrol,我對定位的整個想法陷入了困境。 解決此問題的一個好的替代方法是什么?
有人可以幫忙嗎? 非常感謝!
記住, ContentControl
本身就是一個Control
,允許您嵌套它們:
在VS2013 C#中編譯
<ContentControl>
<ItemsControl>
<!-- One shape in the top level parent. -->
<Ellipse Width="100" Height="100" Stroke="#FFDE3737" />
<ContentControl>
<ItemsControl>
<!-- Multiple shapes in one sub-parent -->
<Ellipse Width="100" Height="100" Stroke="#FFDE3737" />
<Ellipse Width="100" Height="100" Stroke="#FFDE3737" />
</ItemsControl>
</ContentControl>
</ItemsControl>
</ContentControl>
編輯:了解使用WPF合成時的有用提示。 許多Controls
都源自同一基本Control
。 以這種方式,它們形成了一種復合模式,使您可以在必要時將它們非常深地嵌套。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.