首页 文章

WPF拖放创建位置布局

提问于
浏览
0

我一直在讨论wpf拖放的想法 . 到目前为止,我尝试了下面的示例列表,但它对我没有帮助 .

https://codeblitz.wordpress.com/2009/06/26/wpf-itemscontrol-drag-drop-behavior/

https://github.com/dotnet/docs/tree/master/samples/snippets/csharp/VS_Snippets_Wpf/DragDropWalkthrough/CS

https://www.codeproject.com/Articles/17266/Drag-and-Drop-Items-in-a-WPF-ListView

http://www.dotnetlead.com/ - >这是答案,但技术似乎很老 .

My question in here ;用户可以通过拖放对象或其他任何内容来安排该位置中包含的位置和项目 . 我想在这张图片中做什么,你可以在这里看到:
wpf drag drop example image
. image2:https://ibb.co/jhip2c,用户将对象从对象列表(图像左侧)拖动到右侧(usercontrol,换行面板等) . 为此,我也可以使用DevExpress工具 .

解决方案我也尝试了treeList,但它不是我的教师的请求 .

我也很期待任何例子 . 所以,请留下评论 .

谢谢..

1 回答

  • 0

    由于您可以访问DevExpress控件,我建议使用他们的 LayoutControl . 它支持grouping, tabs, and handles label positioning for you . 它还允许用户输入customization mode,其中他们可以使用拖放添加,删除和重新排列项目 . 根据您提供的模型,这可能是您的教练要求您做的事情,因为机制看起来相同:

    Screenshot

    从DevExpress的帮助库中,下面是使用此系统创建包含独立字段,组和选项卡的非平凡布局的example

    <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:lc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
            Height="300"
            Width="572">
      <Grid>
        <lc:LayoutControl Orientation="Vertical">
          <lc:LayoutGroup Orientation="Horizontal">
            <lc:LayoutGroup Orientation="Vertical">
              <lc:LayoutGroup Orientation="Horizontal" View="GroupBox" Header="Group 1" IsCollapsible="True">
                <lc:LayoutItem Label="Item 1:" VerticalAlignment="Stretch">
                  <TextBox/>
                </lc:LayoutItem>
                <lc:LayoutGroup Orientation="Vertical" lc:LayoutControl.AllowHorizontalSizing="True">
                  <lc:LayoutItem Label="Item 2:" VerticalAlignment="Stretch">
                    <TextBox/>
                  </lc:LayoutItem>
                  <lc:LayoutItem Label="Item 3:" VerticalAlignment="Stretch">
                    <TextBox/>
                  </lc:LayoutItem>
                </lc:LayoutGroup>
              </lc:LayoutGroup>
              <lc:LayoutItem Label="Item 4:"  VerticalAlignment="Stretch" lc:LayoutControl.AllowVerticalSizing="True">
                <TextBox/>
              </lc:LayoutItem>
            </lc:LayoutGroup>
            <lc:LayoutGroup View="Tabs" lc:LayoutControl.AllowHorizontalSizing="True">
              <lc:LayoutGroup Header="Tab 1" Orientation="Vertical">
                <lc:LayoutItem Label="Item 5:">
                  <TextBox/>
                </lc:LayoutItem>
                <lc:LayoutItem Label="Item 6:" VerticalAlignment="Stretch">
                  <TextBox/>
                </lc:LayoutItem>
              </lc:LayoutGroup>
              <lc:LayoutGroup Header="Tab 2" Orientation="Vertical">
                <lc:LayoutItem Label="Item 7:">
                  <TextBox/>
                </lc:LayoutItem>
                <lc:LayoutItem Label="Item 8:">
                  <TextBox/>
                </lc:LayoutItem>
              </lc:LayoutGroup>
            </lc:LayoutGroup>
          </lc:LayoutGroup>
          <lc:LayoutGroup Orientation="Horizontal">
            <lc:LayoutItem Label="Item 9:" HorizontalAlignment="Left">
              <TextBox Width="100"/>
            </lc:LayoutItem>
            <lc:LayoutItem Label="Item 10:">
              <TextBox/>
            </lc:LayoutItem>
            <lc:LayoutItem Label="Item 11:" HorizontalAlignment="Right">
              <TextBox Width="100"/>
            </lc:LayoutItem>
          </lc:LayoutGroup>
        </lc:LayoutControl>
      </Grid>
    </Window>
    

    结果如下所示:

    Screenshot of Example Results

相关问题