This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
MainWindow.axaml
134 lines (120 loc) · 4.86 KB
/
MainWindow.axaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:DragAndDropSample.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
xmlns:idd="clr-namespace:Avalonia.Xaml.Interactions.DragAndDrop;assembly=Avalonia.Xaml.Interactions"
xmlns:b="using:DragAndDropSample.Behaviors"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="650" d:DesignHeight="450"
x:Class="DragAndDropSample.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Width="650" WindowStartupLocation="CenterScreen"
Title="DragAndDropSample">
<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>
<Window.Styles>
<Style Selector="ListBox.ItemsDragAndDrop">
<Style.Resources>
<b:ItemsListBoxDropHandler x:Key="ItemsListBoxDropHandler" />
</Style.Resources>
<Setter Property="(i:Interaction.Behaviors)">
<i:BehaviorCollectionTemplate>
<i:BehaviorCollection>
<idd:ContextDropBehavior Handler="{StaticResource ItemsListBoxDropHandler}" />
</i:BehaviorCollection>
</i:BehaviorCollectionTemplate>
</Setter>
</Style>
<Style Selector="ListBox.ItemsDragAndDrop ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="(i:Interaction.Behaviors)">
<i:BehaviorCollectionTemplate>
<i:BehaviorCollection>
<idd:ContextDragBehavior HorizontalDragThreshold="3" VerticalDragThreshold="3" />
</i:BehaviorCollection>
</i:BehaviorCollectionTemplate>
</Setter>
</Style>
<Style Selector="ListBox.NodesDragAndDrop">
<Style.Resources>
<b:NodesListBoxDropHandler x:Key="NodesListBoxDropHandler" />
</Style.Resources>
<Setter Property="(i:Interaction.Behaviors)">
<i:BehaviorCollectionTemplate>
<i:BehaviorCollection>
<idd:ContextDropBehavior Handler="{StaticResource NodesListBoxDropHandler}" />
</i:BehaviorCollection>
</i:BehaviorCollectionTemplate>
</Setter>
</Style>
<Style Selector="ListBox.NodesDragAndDrop ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="(i:Interaction.Behaviors)">
<i:BehaviorCollectionTemplate>
<i:BehaviorCollection>
<idd:ContextDragBehavior />
</i:BehaviorCollection>
</i:BehaviorCollectionTemplate>
</Setter>
</Style>
<Style Selector="TreeView.NodesDragAndDrop">
<Style.Resources>
<b:NodesTreeViewDropHandler x:Key="NodesTreeViewDropHandler" />
</Style.Resources>
<Setter Property="(i:Interaction.Behaviors)">
<i:BehaviorCollectionTemplate>
<i:BehaviorCollection>
<idd:ContextDropBehavior Handler="{StaticResource NodesTreeViewDropHandler}" />
</i:BehaviorCollection>
</i:BehaviorCollectionTemplate>
</Setter>
</Style>
<Style Selector="TreeView.NodesDragAndDrop TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
<Setter Property="(i:Interaction.Behaviors)">
<i:BehaviorCollectionTemplate>
<i:BehaviorCollection>
<idd:ContextDragBehavior />
</i:BehaviorCollection>
</i:BehaviorCollectionTemplate>
</Setter>
</Style>
</Window.Styles>
<TabControl>
<TabItem Header="TreeView">
<Grid ColumnDefinitions="*,8,*">
<TreeView Items="{Binding Nodes}"
Classes="NodesDragAndDrop"
Grid.Column="0">
<TreeView.ItemTemplate>
<TreeDataTemplate DataType="vm:NodeViewModel" ItemsSource="{Binding Nodes}">
<TextBlock Text="{Binding Title}" />
</TreeDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<GridSplitter Width="8" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" Background="Transparent" Grid.Column="1"/>
<ListBox Items="{Binding Nodes}"
Classes="NodesDragAndDrop"
Grid.Column="2">
<ListBox.ItemTemplate>
<DataTemplate DataType="vm:NodeViewModel">
<TextBlock Text="{Binding Title}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</TabItem>
<TabItem Header="ListBox">
<ListBox Items="{Binding Items}"
Classes="ItemsDragAndDrop">
<ListBox.ItemTemplate>
<DataTemplate DataType="vm:ItemViewModel">
<TextBlock Text="{Binding Title}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</TabItem>
</TabControl>
</Window>