This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml
175 lines (175 loc) · 11.4 KB
/
MainWindow.xaml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<Window x:Class="Q453145.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:local="clr-namespace:Q453145"
xmlns:mvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<Grid.Resources>
<DataTemplate x:Key="rowInfoTemplate">
<dxg:NameTextControl NameValue="Row" TextValue="{Binding}" />
</DataTemplate>
<DataTemplate x:Key="dragInfoTemplate">
<Border Padding="12,8,24,10">
<StackPanel>
<TextBlock Name="rowCountTextBlock" Foreground="#FF949494" FontWeight="Bold">
<TextBlock.Text>
<Binding Path="DraggingRows.Count" StringFormat="Dragging {0} rows" />
</TextBlock.Text>
<TextBlock.Visibility>
<Binding Path="DraggingRows.Count">
<Binding.Converter>
<dxg:CountToVisibilityConverter />
</Binding.Converter>
</Binding>
</TextBlock.Visibility>
</TextBlock>
<TextBlock Name="oneRowTextBlock" Foreground="#FF949494" FontWeight="Bold" Text="Dragging 1 row:">
<TextBlock.Visibility>
<Binding Path="DraggingRows.Count">
<Binding.Converter>
<dxg:CountToVisibilityConverter Invert="True" />
</Binding.Converter>
</Binding>
</TextBlock.Visibility>
</TextBlock>
<ContentPresenter Name="rowInfoDragPresenter" Content="{Binding FirstDraggingObject}" ContentTemplate="{StaticResource rowInfoTemplate}">
<ContentPresenter.Visibility>
<Binding Path="DataContext.DraggingRows.Count" RelativeSource="{RelativeSource TemplatedParent}">
<Binding.Converter>
<dxg:CountToVisibilityConverter Invert="True" />
</Binding.Converter>
</Binding>
</ContentPresenter.Visibility>
</ContentPresenter>
</StackPanel>
</Border>
</DataTemplate>
<DataTemplate x:Key="dropInfoTemplate">
<Border Name="border" CornerRadius="0,0,5,5" Padding="12,8,24,10" BorderThickness="0,1,0,0">
<Border.Background>
<Binding Path="DropTargetType">
<Binding.Converter>
<dx:EnumToObjectConverter DefaultValue="#FFF0F0F0">
<dx:EnumToObjectConverter.Values>
<dx:EnumObjectProvider x:Key="None" Value="#FFEBADB4" />
</dx:EnumToObjectConverter.Values>
</dx:EnumToObjectConverter>
</Binding.Converter>
</Binding>
</Border.Background>
<Border.BorderBrush>
<Binding Path="DropTargetType">
<Binding.Converter>
<dx:EnumToObjectConverter DefaultValue="#FFC8C8C8">
<dx:EnumToObjectConverter.Values>
<dx:EnumObjectProvider x:Key="None" Value="#FFFFD0D6" />
</dx:EnumToObjectConverter.Values>
</dx:EnumToObjectConverter>
</Binding.Converter>
</Binding>
</Border.BorderBrush>
<StackPanel>
<TextBlock Name="dropInfoText" FontWeight="Bold">
<TextBlock.Text>
<Binding Path="DropTargetType">
<Binding.Converter>
<dx:EnumToObjectConverter>
<dx:EnumToObjectConverter.Values>
<dx:EnumObjectProvider x:Key="None" Value="Cannot drop here" />
<dx:EnumObjectProvider x:Key="DataArea" Value="Add rows" />
<dx:EnumObjectProvider x:Key="InsertRowsIntoGroup" Value="Move to group:" />
<dx:EnumObjectProvider x:Key="InsertRowsIntoNode" Value="Move to children collection:" />
<dx:EnumObjectProvider x:Key="InsertRowsAfter" Value="Insert after row:" />
<dx:EnumObjectProvider x:Key="InsertRowsBefore" Value="Insert before row:" />
</dx:EnumToObjectConverter.Values>
</dx:EnumToObjectConverter>
</Binding.Converter>
</Binding>
</TextBlock.Text>
<TextBlock.Foreground>
<Binding Path="DropTargetType">
<Binding.Converter>
<dx:EnumToObjectConverter DefaultValue="#FF949494">
<dx:EnumToObjectConverter.Values>
<dx:EnumObjectProvider x:Key="None" Value="#FFB34242" />
</dx:EnumToObjectConverter.Values>
</dx:EnumToObjectConverter>
</Binding.Converter>
</Binding>
</TextBlock.Foreground>
</TextBlock>
<ContentPresenter Name="rowInfoPresenter" Content="{Binding DropTargetRow}" ContentTemplate="{StaticResource rowInfoTemplate}">
<ContentPresenter.Visibility>
<Binding Path="DataContext.DropTargetType" RelativeSource="{RelativeSource TemplatedParent}">
<Binding.Converter>
<dx:EnumToObjectConverter DefaultValue="Collapsed">
<dx:EnumToObjectConverter.Values>
<dx:EnumObjectProvider x:Key="InsertRowsAfter" Value="Visible" />
<dx:EnumObjectProvider x:Key="InsertRowsBefore" Value="Visible" />
<dx:EnumObjectProvider x:Key="InsertRowsIntoNode" Value="Visible" />
</dx:EnumToObjectConverter.Values>
</dx:EnumToObjectConverter>
</Binding.Converter>
</Binding>
</ContentPresenter.Visibility>
</ContentPresenter>
<ItemsControl Name="groupInfoItemsControl" ItemsSource="{Binding GroupInfo}">
<ItemsControl.Visibility>
<Binding Path="DataContext.DropTargetType" RelativeSource="{RelativeSource TemplatedParent}">
<Binding.Converter>
<dx:EnumToObjectConverter DefaultValue="Collapsed">
<dx:EnumToObjectConverter.Values>
<dx:EnumObjectProvider x:Key="InsertRowsIntoGroup" Value="Visible" />
</dx:EnumToObjectConverter.Values>
</dx:EnumToObjectConverter>
</Binding.Converter>
</Binding>
</ItemsControl.Visibility>
<ItemsControl.ItemTemplate>
<DataTemplate>
<dxg:NameTextControl x:Name="groupInfoControl" NameValue="{Binding FieldName}" TextValue="{Binding Value}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Source={x:Static interop:BrowserInteropHelper.IsBrowserHosted}}" Value="True" xmlns:interop="clr-namespace:System.Windows.Interop;assembly=PresentationFramework">
<Setter Property="CornerRadius" TargetName="border" Value="0,0,0,0" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate x:Key="dragElementTemplate">
<dxg:HintControl>
<StackPanel>
<ContentPresenter Name="dragInfo" Content="{Binding}" ContentTemplate="{StaticResource dragInfoTemplate}" />
<ContentPresenter Name="dropInfo" Content="{Binding}" ContentTemplate="{StaticResource dropInfoTemplate}" />
<TextBlock Name="actionTextBlock" HorizontalAlignment="Center" />
<TextBlock Name="hintTextBlock" FontStyle="Italic" HorizontalAlignment="Center" />
</StackPanel>
</dxg:HintControl>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=(local:CopyRowsHelper.CopyRows)}" Value="True">
<Setter Property="Text" TargetName="actionTextBlock" Value="Copying rows.." />
<Setter Property="Text" TargetName="hintTextBlock" Value="Release CTRL to move" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=(local:CopyRowsHelper.CopyRows)}" Value="False">
<Setter Property="Text" TargetName="actionTextBlock" Value="Moving rows.." />
<Setter Property="Text" TargetName="hintTextBlock" Value="Hold CTRL to copy" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</Grid.Resources>
<dxg:TreeListControl Name="treeListControl1" AutoPopulateColumns="True" PreviewKeyDown="treeListControl1_PreviewKeyDown" PreviewKeyUp="treeListControl1_PreviewKeyDown">
<dxg:TreeListControl.View>
<dxg:TreeListView Name="treeListView1" KeyFieldName="Id" ParentFieldName="ParentId" NavigationStyle="Row" AutoExpandAllNodes="True"/>
</dxg:TreeListControl.View>
<mvvm:Interaction.Behaviors>
<dxg:TreeListDragDropManager x:Name="dropManager" DragElementTemplate="{StaticResource dragElementTemplate}" Drop="dropManager_Drop"/>
</mvvm:Interaction.Behaviors>
</dxg:TreeListControl>
</Grid>
</Window>