添加项目文件。

This commit is contained in:
akwkevin
2021-07-23 09:42:22 +08:00
commit f25a958797
2798 changed files with 352360 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
<UserControl x:Class="Showcase.WPF.DragDrop.Views.DataGridSamples"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
d:DesignHeight="300"
d:DesignWidth="300"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource DefaultDataGridStyle}" TargetType="{x:Type DataGrid}" />
</Grid.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="DataGrid" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two DataGrids bound to two collections of the same type. Just try drag and drop some Rows from left DataGrid to right DataGrid." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<DataGrid x:Name="LeftBoundDataGrid"
Grid.Column="0"
dd:DragDrop.DropScrollingMode="VerticalOnly"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
CanUserAddRows="False"
CanUserDeleteRows="False"
IsReadOnly="True"
ItemsSource="{Binding Data.DataGridCollection1}" />
<DataGrid Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
CanUserAddRows="True"
CanUserDeleteRows="True"
ItemsSource="{Binding Data.DataGridCollection2}" />
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left DataGrid)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftBoundDataGrid, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftBoundDataGrid, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftBoundDataGrid, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftBoundDataGrid, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</Grid>
</UserControl>

View File

@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace Showcase.WPF.DragDrop.Views
{
/// <summary>
/// Interaction logic for DataGridSamples.xaml
/// </summary>
public partial class DataGridSamples : UserControl
{
public DataGridSamples()
{
InitializeComponent();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace Showcase.WPF.DragDrop.Views
{
/// <summary>
/// Interaction logic for Issues.xaml
/// </summary>
public partial class Issues : UserControl
{
public Issues()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,460 @@
<UserControl x:Class="Showcase.WPF.DragDrop.Views.ListBoxSamples"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
d:DesignHeight="400"
d:DesignWidth="600"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource DefaultListBoxStyle}" TargetType="{x:Type ListBox}" />
</Grid.Resources>
<TabControl Style="{StaticResource ShowcaseTabControlStyle}">
<TabItem Header="Bound">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListBox Bound" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two ListBoxes bound to two collections of the same type. Just try drag and drop some Items from left ListBox to right ListBox." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox x:Name="LeftBoundListBox"
Grid.Column="0"
dd:DragDrop.CanDragWithMouseRightButton="True"
dd:DragDrop.DropTargetAdornerBrush="Coral"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection1}" />
<ListBox Grid.Column="1"
dd:DragDrop.DropTargetAdornerBrush="Coral"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
ItemsSource="{Binding Data.Collection2}" />
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="CanDragWithMouseRightButton"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.CanDragWithMouseRightButton), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Unbound">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListBox Unbound" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two ListBoxes and unbound items (e.g. direct usage of ListBoxItem). Just try drag and drop some Items from left ListBox to right ListBox." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox x:Name="LeftUnboundListBox"
Grid.Column="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True">
<ListBoxItem>Unbound Item1</ListBoxItem>
<ListBoxItem>Unbound Item2</ListBoxItem>
<ListBoxItem>Unbound Item3</ListBoxItem>
<ListBoxItem>Unbound Item4</ListBoxItem>
<ListBoxItem>Unbound Item5</ListBoxItem>
</ListBox>
<ListBox Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True">
<ListBoxItem>Unbound Item6</ListBoxItem>
<ListBoxItem>Unbound Item7</ListBoxItem>
<ListBoxItem>Unbound Item8</ListBoxItem>
<ListBoxItem>Unbound Item9</ListBoxItem>
<ListBoxItem>Unbound Item10</ListBoxItem>
</ListBox>
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftUnboundListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftUnboundListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftUnboundListBox, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftUnboundListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Horizontal">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListBox Horizontal" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with horizontal ListBoxes and right to left flow direction." />
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Unbound ListBox" />
<ListBox Height="Auto"
dd:DragDrop.DefaultDragAdornerOpacity="0.5"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="1" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem>ListBoxItem1</ListBoxItem>
<ListBoxItem>ListBoxItem2</ListBoxItem>
<ListBoxItem>ListBoxItem3</ListBoxItem>
<ListBoxItem>ListBoxItem4</ListBoxItem>
<ListBoxItem>ListBoxItem5</ListBoxItem>
</ListBox>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="ListBox bound to a collection" />
<ListBox Height="Auto"
dd:DragDrop.DefaultDragAdornerOpacity="0.5"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemsSource="{Binding Data.Collection1}"
SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="1" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="ListBox with right to left flow direction for the ItemsPanel" />
<ListBox Height="Auto"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="1"
FlowDirection="RightToLeft"
Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem>ListBoxItem6</ListBoxItem>
<ListBoxItem>ListBoxItem7</ListBoxItem>
<ListBoxItem>ListBoxItem8</ListBoxItem>
<ListBoxItem>ListBoxItem9</ListBoxItem>
<ListBoxItem>ListBoxItem10</ListBoxItem>
</ListBox>
<TextBlock Margin="4 8 4 4"
Style="{StaticResource DefaultTextBlockStyle}"
Text="FlowDirection=&quot;RightToLeft&quot; for the ItemsPanel doesn't work in this case! The insertion adorner will be wrong calculated." />
<ListBox Height="Auto"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemContainerStyle="{x:Null}"
SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="1"
FlowDirection="RightToLeft"
Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<Rectangle Width="100"
Height="60"
Fill="LightCoral"
Stroke="Black" />
<Rectangle Width="120"
Height="60"
Fill="LightCyan"
Stroke="Black" />
<Rectangle Width="140"
Height="60"
Fill="LightGreen"
Stroke="Black" />
<Rectangle Width="160"
Height="60"
Fill="LightPink"
Stroke="Black" />
</ListBox>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Set RotateTransform of ListBox to ScaleTransform ScaleX=&quot;-1&quot;." />
<ListBox Height="Auto"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemContainerStyle="{x:Null}"
RenderTransformOrigin="0.5,0.5"
SelectionMode="Extended">
<ListBox.RenderTransform>
<ScaleTransform ScaleX="-1" />
</ListBox.RenderTransform>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="1" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<Rectangle Width="100"
Height="60"
Fill="LightCoral"
Stroke="Black" />
<Rectangle Width="120"
Height="60"
Fill="LightCyan"
Stroke="Black" />
<Rectangle Width="140"
Height="60"
Fill="LightGreen"
Stroke="Black" />
<Rectangle Width="160"
Height="60"
Fill="LightPink"
Stroke="Black" />
</ListBox>
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Grouping">
<TabItem.Resources>
<CollectionViewSource x:Key="GroupedCollectionViewSource" Source="{Binding Data.GroupedCollection}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Group" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListBox Grouping" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the behaviour with a ListBox which is bound to a grouped collection (CollectionViewSource). The ListBox uses also a custom DropHandler to handle the drop action." />
<ListBox x:Name="GroupedListBox"
dd:DragDrop.DragDirectlySelectedOnly="True"
dd:DragDrop.DropHandler="{Binding Data.GroupedDropHandler}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
DisplayMemberPath="Caption"
ItemsSource="{Binding Source={StaticResource GroupedCollectionViewSource}}"
SelectionMode="Extended">
<ListBox.GroupStyle>
<x:Static Member="GroupStyle.Default" />
</ListBox.GroupStyle>
</ListBox>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=GroupedListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=GroupedListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=GroupedListBox, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=GroupedListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="DragDropKeyStates">
<TabItem.Resources>
<ObjectDataProvider x:Key="DragDropKeyStatesEnumValues"
MethodName="GetValues"
ObjectType="{x:Type DragDropKeyStates}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="DragDropKeyStates" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListBox DragDropKeyStates" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the DragDropCopyKeyState behaviour with two ListBoxes bound to two collections of the same type. Try changing the DragDropCopyKeyState for the left ListBox and see what happens." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox x:Name="LeftListBoxOfDragDropKeyStatesSample"
Grid.Column="0"
dd:DragDrop.DragDropCopyKeyState="ControlKey"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection1}" />
<ListBox Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemsSource="{Binding Data.Collection2}" />
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
<StackPanel Margin="10 5" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="DragDropCopyKeyState" />
<ComboBox Width="200"
Margin="5 0 0 0"
VerticalAlignment="Center"
ItemsSource="{Binding Source={StaticResource DragDropKeyStatesEnumValues}}"
SelectedItem="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.DragDropCopyKeyState), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="List in List">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListBox List in List" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="This sample comes from an issue and demonstrates the behaviour of nested ListBoxes." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0"
Height="450"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemsSource="{Binding Data.Collection1}" />
<ListBox x:Name="Outer"
Grid.Column="1"
Height="450"
dd:DragDrop.IsDropTarget="True">
<Border BorderBrush="Silver" BorderThickness="1">
<ListBox x:Name="Inner1"
Width="200"
Height="150"
HorizontalContentAlignment="Stretch"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
Background="DarkOrange"
ItemsSource="{Binding Data.Collection2}" />
</Border>
<Border BorderBrush="Silver" BorderThickness="1">
<ListBox x:Name="Inner2"
Width="200"
Height="150"
HorizontalContentAlignment="Stretch"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
Background="DarkSeaGreen">
<ListBoxItem Content="ListBoxItem1" />
<ListBoxItem Content="ListBoxItem2" />
</ListBox>
</Border>
</ListBox>
</Grid>
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Undraggable List in List">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListBox Undraggable List in List" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="This sample comes from an issue and demonstrates the behaviour of nested ListBoxes that can be dragged in the outer ListBox while their own items cannot be dragged" />
<ListBox x:Name="Outer2"
Height="450"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True">
<Border BorderBrush="Silver" BorderThickness="1">
<ListBox x:Name="Inner3"
Width="200"
Height="150"
HorizontalContentAlignment="Stretch"
Background="HotPink">
<ListBoxItem Content="ListBoxItem1 Inner3" />
<ListBoxItem Content="ListBoxItem2 Inner3" />
</ListBox>
</Border>
<Border BorderBrush="Silver" BorderThickness="1">
<ListBox x:Name="Inner4"
Width="200"
Height="150"
HorizontalContentAlignment="Stretch"
Background="LightSkyBlue">
<ListBoxItem Content="ListBoxItem1 Inner4" />
<ListBoxItem Content="ListBoxItem2 Inner4" />
<ListBoxItem Content="ListBoxItem3 Inner4" />
</ListBox>
</Border>
</ListBox>
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
</TabControl>
</Grid>
</UserControl>

View File

@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace Showcase.WPF.DragDrop.Views
{
/// <summary>
/// Interaction logic for ListBoxSample.xaml
/// </summary>
public partial class ListBoxSamples : UserControl
{
public ListBoxSamples()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,223 @@
<UserControl x:Class="Showcase.WPF.DragDrop.Views.ListViewSamples"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
d:DesignHeight="400"
d:DesignWidth="600"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource DefaultListViewStyle}" TargetType="{x:Type ListView}" />
</Grid.Resources>
<TabControl Style="{StaticResource ShowcaseTabControlStyle}">
<TabItem Header="Bound">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListView Bound" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two ListViews bound to two collections of the same type. Just try drag and drop some Items from left ListView to right ListView." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListView x:Name="LeftBoundListView"
Grid.Column="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
ItemsSource="{Binding Data.Collection1}">
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<iconPacks:PackIconMaterial Focusable="False"
Foreground="Gray"
Kind="File" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Header="ContextMenu Item 1" />
<MenuItem Header="ContextMenu Item 2" />
<MenuItem Header="ContextMenu Item 3" />
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<ListView Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemsSource="{Binding Data.Collection2}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" SharedSizeGroup="CaptionColum" />
</Grid.ColumnDefinitions>
<iconPacks:PackIconMaterial Grid.Column="0"
Focusable="False"
Foreground="Gray"
Kind="FileDocument" />
<TextBlock Grid.Column="1"
VerticalAlignment="Center"
Text="{Binding}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
Grid.IsSharedSizeScope="True"
Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListView)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftBoundListView, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftBoundListView, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftBoundListView, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftBoundListView, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Unbound">
<TabItem.Resources>
<Style x:Key="CustomLeftUnboundListViewItemStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" SharedSizeGroup="CaptionColum" />
</Grid.ColumnDefinitions>
<iconPacks:PackIconMaterial Grid.Column="0"
Focusable="False"
Foreground="Gray"
Kind="File" />
<TextBlock Grid.Column="1"
VerticalAlignment="Center"
Text="{Binding}" />
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Padding" Value="2" />
</Style>
<Style x:Key="CustomRightUnboundListViewItemStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" SharedSizeGroup="CaptionColum" />
</Grid.ColumnDefinitions>
<iconPacks:PackIconMaterial Grid.Column="0"
Focusable="False"
Foreground="Gray"
Kind="FileDocument" />
<TextBlock Grid.Column="1"
VerticalAlignment="Center"
Text="{Binding}" />
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Padding" Value="2" />
</Style>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="ListView Unbound" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two ListViews and unbound items (e.g. direct usage of ListViewItem). Just try drag and drop some Items from left ListView to right ListView." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListView x:Name="LeftUnboundListView"
Grid.Column="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemContainerStyle="{StaticResource CustomLeftUnboundListViewItemStyle}">
<ListViewItem>Unbound Item1</ListViewItem>
<ListViewItem>Unbound Item2</ListViewItem>
<ListViewItem>Unbound Item3</ListViewItem>
<ListViewItem>Unbound Item4</ListViewItem>
<ListViewItem>Unbound Item5</ListViewItem>
</ListView>
<ListView Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemContainerStyle="{StaticResource CustomRightUnboundListViewItemStyle}">
<ListViewItem>Unbound Item6</ListViewItem>
<ListViewItem>Unbound Item7</ListViewItem>
<ListViewItem>Unbound Item8</ListViewItem>
<ListViewItem>Unbound Item9</ListViewItem>
<ListViewItem>Unbound Item10</ListViewItem>
</ListView>
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListView)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftUnboundListView, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftUnboundListView, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftUnboundListView, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftUnboundListView, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
</TabControl>
</Grid>
</UserControl>

View File

@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace Showcase.WPF.DragDrop.Views
{
/// <summary>
/// Interaction logic for ListViewSample.xaml
/// </summary>
public partial class ListViewSamples : UserControl
{
public ListViewSamples()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,603 @@
<UserControl x:Class="Showcase.WPF.DragDrop.Views.MixedSamples"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:Showcase.WPF.DragDrop.Models"
xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
d:DesignHeight="400"
d:DesignWidth="600"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource DefaultItemsControl}" TargetType="{x:Type ItemsControl}" />
<Style BasedOn="{StaticResource DefaultListBoxStyle}" TargetType="{x:Type ListBox}" />
<Style BasedOn="{StaticResource DefaultListViewStyle}" TargetType="{x:Type ListView}" />
<Style BasedOn="{StaticResource DefaultTreeViewStyle}" TargetType="{x:Type TreeView}" />
</Grid.Resources>
<TabControl x:Name="MixedTabControl" Style="{StaticResource ShowcaseTabControlStyle}">
<TabControl.Resources>
<DataTemplate x:Key="DragAdorner">
<Border Background="Silver"
BorderBrush="Gray"
BorderThickness="1"
CornerRadius="2"
SnapsToDevicePixels="True">
<StackPanel Margin="4" Orientation="Horizontal">
<iconPacks:PackIconMaterial VerticalAlignment="Center" Kind="MoveResizeVariant" />
<TextBlock Margin="6 0 0 0"
VerticalAlignment="Center"
Text="{Binding}" />
</StackPanel>
</Border>
</DataTemplate>
</TabControl.Resources>
<TabItem Header="DragAdorner">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="DragAdorner" />
<UniformGrid Columns="2" Rows="1">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource DefaultTextBlockStyle}"
Text="ListBox" />
<ListBox Height="Auto"
dd:DragDrop.DragAdornerTemplate="{StaticResource DragAdorner}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection1}" />
</DockPanel>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource DefaultTextBlockStyle}"
Text="ListView" />
<ListView Height="Auto"
dd:DragDrop.DragAdornerTemplate="{StaticResource DragAdorner}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection2}" />
</DockPanel>
</UniformGrid>
</DockPanel>
</TabItem>
<TabItem Header="DragDropContext">
<TabItem.Resources>
<Style BasedOn="{StaticResource DefaultListBoxStyle}" TargetType="{x:Type ListBox}">
<Setter Property="Height" Value="Auto" />
</Style>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="DragDropContext sample" />
<UniformGrid Columns="2" Rows="2">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource DefaultTextBlockStyle}"
Text="DragDropContext = MainContext" />
<ListBox Height="Auto"
dd:DragDrop.DragDropContext="MainContext"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection1}" />
</DockPanel>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource DefaultTextBlockStyle}"
Text="DragDropContext = MainContext" />
<ListBox Height="Auto"
dd:DragDrop.DragDropContext="MainContext"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection2}" />
</DockPanel>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource DefaultTextBlockStyle}"
Text="DragDropContext = DifferentContext" />
<ListBox Height="Auto"
dd:DragDrop.DragDropContext="DifferentContext"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection2}" />
</DockPanel>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource DefaultTextBlockStyle}"
Text="No DragDropContext" />
<ListBox Height="Auto"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection4}" />
</DockPanel>
</UniformGrid>
</DockPanel>
</TabItem>
<TabItem Header="Filtered">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="Filtered ListBox" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the behaviour with a filtered and unfiltered ListBox bound to two collections of the same type." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox x:Name="LeftFilterListBox"
Grid.Column="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.FilterCollection1}" />
<ListBox Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemsSource="{Binding Data.FilterCollection2}" />
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
<CheckBox Margin="10 5"
Command="{Binding FilterCollectionCommand, Mode=OneWay}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}"
Content="Filter by %2" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftFilterListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftFilterListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftFilterListBox, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftFilterListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Custom styled ItemsControl">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="Custom styled ItemsControl" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="A custom styles ItemsControl on the left side. It's here to check if it works... yes, really." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ItemsControl Grid.Column="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemsSource="{Binding Data.Collection1}">
<ItemsControl.Style>
<Style BasedOn="{StaticResource DefaultItemsControl}" TargetType="{x:Type ItemsControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<Border Background="WhiteSmoke">
<ScrollViewer>
<ItemsPresenter />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ItemsControl.Style>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="4" Background="Bisque">
<TextBlock Text="{Binding}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ListBox Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemsSource="{Binding Data.Collection2}" />
</Grid>
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="DragAdornerTemplateSelector">
<TabItem.Resources>
<DataTemplate x:Key="Even">
<Border Background="Gainsboro"
BorderBrush="Silver"
BorderThickness="1"
CornerRadius="2">
<TextBlock Margin="2"
FontWeight="Bold"
Foreground="Green"
Text="{Binding}" />
</Border>
</DataTemplate>
<DataTemplate x:Key="Odd">
<Border Background="Gainsboro"
BorderBrush="Silver"
BorderThickness="1"
CornerRadius="2">
<TextBlock Margin="2"
FontWeight="Bold"
Foreground="DodgerBlue"
Text="{Binding}" />
</Border>
</DataTemplate>
<models:DragAdornerTemplateSelector x:Key="DragAdornerTemplateSelector"
TemplateEven="{StaticResource Even}"
TemplateOdd="{StaticResource Odd}" />
<DataTemplate x:Key="DropAdornerTemplate">
<Border Background="GhostWhite"
BorderBrush="Black"
BorderThickness="1">
<DockPanel LastChildFill="True">
<iconPacks:PackIconOcticons Margin="4"
VerticalAlignment="Center"
DockPanel.Dock="Left"
Kind="Hubot" />
<TextBlock Margin="4"
FontSize="14"
FontWeight="Bold"
Foreground="Crimson"
Text="{Binding}" />
</DockPanel>
</Border>
</DataTemplate>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="DragAdornerTemplateSelector" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the usage of a DataTemplateSelector for the drag adorner." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox x:Name="LeftDataTemplateSelectorSampleListBox"
Grid.Column="0"
dd:DragDrop.DragAdornerTemplateSelector="{StaticResource DragAdornerTemplateSelector}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection1}" />
<ListBox Grid.Column="1"
dd:DragDrop.DropAdornerTemplate="{StaticResource DropAdornerTemplate}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemsSource="{Binding Data.Collection2}" />
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftDataTemplateSelectorSampleListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftDataTemplateSelectorSampleListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftDataTemplateSelectorSampleListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Cloning">
<TabItem.Resources>
<Style x:Key="ClonableListBoxItemStyle"
BasedOn="{StaticResource DefaultListBoxItemStyle}"
TargetType="{x:Type ListBoxItem}">
<Setter Property="dd:DragDrop.DragSourceIgnore" Value="True" />
</Style>
<DataTemplate x:Key="CloningTemplate" DataType="{x:Type models:ClonableItemModel}">
<Border Background="Gainsboro"
BorderBrush="Gray"
BorderThickness="1"
CornerRadius="2"
SnapsToDevicePixels="True">
<StackPanel Margin="4" Orientation="Horizontal">
<iconPacks:PackIconMaterial dd:DragDrop.DragSourceIgnore="False"
Background="Transparent"
Cursor="SizeAll"
Kind="Drag" />
<TextBlock Margin="6 0 0 0"
VerticalAlignment="Center"
Text="{Binding Caption}" />
</StackPanel>
</Border>
</DataTemplate>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="Cloning" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the cloning behaviour with 2 ListBoxes bound to collections of the same type. The Model of the collections implements the ICloneable interface. You can clone an Item by holding the CTRL key while drag and drop." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox x:Name="LeftClonableListBox"
Grid.Column="0"
HorizontalContentAlignment="Stretch"
dd:DragDrop.DragAdornerTemplate="{StaticResource CloningTemplate}"
dd:DragDrop.DragDropCopyKeyState="ControlKey"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemContainerStyle="{StaticResource ClonableListBoxItemStyle}"
ItemTemplate="{StaticResource CloningTemplate}"
ItemsSource="{Binding Data.ClonableCollection1}" />
<ListBox Grid.Column="1"
HorizontalContentAlignment="Stretch"
dd:DragDrop.DragAdornerTemplate="{StaticResource CloningTemplate}"
dd:DragDrop.DragDropCopyKeyState="ControlKey"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemContainerStyle="{StaticResource ClonableListBoxItemStyle}"
ItemTemplate="{StaticResource CloningTemplate}"
ItemsSource="{Binding Data.ClonableCollection2}" />
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftClonableListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftClonableListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftClonableListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="ItemsControl">
<TabItem.Resources />
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="Another ItemsControl sample" />
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource DefaultTextBlockStyle}"
Text="Demonstrates the behaviour with an ItemsControl that has a DataTemplate with an ItemsControl and Buttons inside." />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<ItemsControl Height="Auto"
dd:DragDrop.DragAdornerTemplate="{StaticResource DragAdorner}"
dd:DragDrop.DragDropContext="OuterContext"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection1}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0 1 0 1" Background="Coral">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="2"
FontSize="16"
Text="{Binding}" />
<ItemsControl Grid.Row="1"
Height="Auto"
dd:DragDrop.DragDropContext="InnerContext"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemsSource="{Binding SubItemCollection, Mode=OneWay}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type models:SubItemModel}">
<Grid Background="#FDA07E">
<StackPanel Orientation="Horizontal">
<Button Margin="20 0 10 0"
VerticalAlignment="Center"
Command="{Binding ButtonTestCommand}"
Content="{Binding Caption}" />
<RadioButton VerticalAlignment="Center"
Content="Option A"
IsChecked="{Binding BindableOptionA}" />
<RadioButton VerticalAlignment="Center"
Content="Option B"
IsChecked="{Binding BindableOptionB}" />
<TextBlock VerticalAlignment="Center" Text="{Binding BindableValue}" />
</StackPanel>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DockPanel>
</DockPanel>
</TabItem>
<TabItem Header="Outside">
<TabItem.Resources />
<DockPanel LastChildFill="True">
<StackPanel DockPanel.Dock="Top" Orientation="Vertical">
<TextBlock Style="{StaticResource SampleHeaderTextBlockStyle}" Text="Drag and drop from one App to another one." />
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates drag and drop action bewteen one application to another one. Just open the other app and try to drag one or more items to this app or vice versa." />
<Button Margin="2"
Click="ButtonOpenAnotherAppOnClick"
Content="Open another application..." />
</StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox x:Name="LeftBoundListBox"
Grid.Column="0"
Height="Auto"
dd:DragDrop.DragHandler="{Binding Data.SerializableDragHandler}"
dd:DragDrop.DropHandler="{Binding Data.SerializableDropHandler}"
dd:DragDrop.DropTargetAdornerBrush="BlueViolet"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.SerializableCollection1}" />
<ListBox Grid.Column="1"
Height="Auto"
dd:DragDrop.DragHandler="{Binding Data.SerializableDragHandler}"
dd:DragDrop.DropHandler="{Binding Data.SerializableDropHandler}"
dd:DragDrop.DropTargetAdornerBrush="BlueViolet"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.SerializableCollection2}" />
</Grid>
<StackPanel Grid.Row="1">
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="CanDragWithMouseRightButton"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.CanDragWithMouseRightButton), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftBoundListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
</DockPanel>
</TabItem>
<TabItem Header="Keep Selection">
<TabItem.Resources />
<DockPanel LastChildFill="True">
<StackPanel DockPanel.Dock="Top" Orientation="Vertical">
<TextBlock Style="{StaticResource SampleHeaderTextBlockStyle}" Text="Keep selection after Drag and drop action." />
</StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox x:Name="LeftBoundKeepSelListBox"
Grid.Column="0"
Height="Auto"
dd:DragDrop.DropTargetAdornerBrush="Crimson"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.SelectDroppedItems="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection1}" />
<ListView Grid.Column="1"
Height="Auto"
dd:DragDrop.DropTargetAdornerBrush="Crimson"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.SelectDroppedItems="True"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
ItemsSource="{Binding Data.Collection2}">
<ListView.ItemTemplate>
<DataTemplate>
<DockPanel LastChildFill="True">
<iconPacks:PackIconMaterial Margin="2"
Focusable="False"
Foreground="DarkOrange"
Kind="CheckboxMarkedOutline" />
<TextBlock Margin="2" Text="{Binding}" />
</DockPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<StackPanel Grid.Row="1">
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftBoundKeepSelListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftBoundKeepSelListBox, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftBoundKeepSelListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="ShowAlwaysDropTargetAdorner"
IsChecked="{Binding ElementName=LeftBoundKeepSelListBox, Path=(dd:DragDrop.ShowAlwaysDropTargetAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="SelectDroppedItems"
IsChecked="{Binding ElementName=LeftBoundKeepSelListBox, Path=(dd:DragDrop.SelectDroppedItems), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
</DockPanel>
</TabItem>
</TabControl>
</Grid>
</UserControl>

View File

@@ -0,0 +1,35 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
namespace Showcase.WPF.DragDrop.Views
{
/// <summary>
/// Interaction logic for MixedSamples.xaml
/// </summary>
public partial class MixedSamples : UserControl
{
public MixedSamples()
{
InitializeComponent();
this.Loaded += MainWindowLoaded;
}
private void MainWindowLoaded(object sender, RoutedEventArgs e)
{
var appArgs = Environment.GetCommandLineArgs();
if (appArgs.Length > 1 && appArgs[1] == "anotherOne")
{
MixedTabControl.SelectedItem = MixedTabControl.Items.OfType<TabItem>().FirstOrDefault(t => (string)t.Header == "Outside");
}
}
private void ButtonOpenAnotherAppOnClick(object sender, RoutedEventArgs e)
{
Process.Start(Assembly.GetEntryAssembly().Location, "anotherOne");
}
}
}

View File

@@ -0,0 +1,144 @@
<UserControl x:Class="Showcase.WPF.DragDrop.Views.TabControlSamples"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:Showcase.WPF.DragDrop.Models"
xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
d:DesignHeight="400"
d:DesignWidth="600"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource DefaultTabControlStyle}" TargetType="{x:Type TabControl}" />
<Style x:Key="CustomTabControlStyle"
BasedOn="{StaticResource DefaultTabControlStyle}"
TargetType="{x:Type TabControl}">
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style BasedOn="{StaticResource DefaultTabItemStyle}" TargetType="{x:Type TabItem}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate DataType="{x:Type models:TabItemModel}">
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="{Binding Content}" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate DataType="{x:Type models:TabItemModel}">
<TextBlock Margin="2" Text="{Binding Header}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<TabControl Style="{StaticResource ShowcaseTabControlStyle}">
<TabItem Header="Bound">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="TabControl Bound" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two TabControls bound to two collections of the same type." />
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="It's currently not possible to drag into an empty TabControl." />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TabControl x:Name="TopBoundTabControl"
Grid.Row="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemsSource="{Binding Data.TabItemCollection1}"
Style="{StaticResource CustomTabControlStyle}" />
<TabControl Grid.Row="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemsSource="{Binding Data.TabItemCollection2}"
Style="{StaticResource CustomTabControlStyle}" />
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for top TabControl)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=TopBoundTabControl, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=TopBoundTabControl, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=TopBoundTabControl, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=TopBoundTabControl, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Unbound">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="TabControl Unbound" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two TabControls and unbound items (e.g. direct usage of TabItem)." />
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="It's currently not possible to drag into an empty TabControl." />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TabControl x:Name="TopUnboundTabControl"
Grid.Row="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True">
<TabItem Header="Unbound Item 1">Content of Unbound Item 1</TabItem>
<TabItem Header="Unbound Item 2">Content of Unbound Item 2</TabItem>
<TabItem Header="Unbound Item 3">Content of Unbound Item 3</TabItem>
<TabItem Header="Unbound Item 4">Content of Unbound Item 4</TabItem>
<TabItem Header="Unbound Item 5">Content of Unbound Item 5</TabItem>
</TabControl>
<TabControl Grid.Row="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True">
<TabItem Header="Unbound Item 6">Content of Unbound Item 6</TabItem>
<TabItem Header="Unbound Item 7">Content of Unbound Item 7</TabItem>
<TabItem Header="Unbound Item 8">Content of Unbound Item 8</TabItem>
<TabItem Header="Unbound Item 9">Content of Unbound Item 9</TabItem>
<TabItem Header="Unbound Item 10">Content of Unbound Item 10</TabItem>
</TabControl>
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for top TabControl)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=TopUnboundTabControl, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=TopUnboundTabControl, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=TopUnboundTabControl, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=TopUnboundTabControl, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
</TabControl>
</Grid>
</UserControl>

View File

@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace Showcase.WPF.DragDrop.Views
{
/// <summary>
/// Interaction logic for TabControlSamples.xaml
/// </summary>
public partial class TabControlSamples : UserControl
{
public TabControlSamples()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,146 @@
<UserControl x:Class="Showcase.WPF.DragDrop.Views.TreeViewSamples"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
d:DesignHeight="400"
d:DesignWidth="600"
mc:Ignorable="d">
<Grid>
<Grid.Resources>
<Style BasedOn="{StaticResource DefaultTreeViewStyle}" TargetType="{x:Type TreeView}" />
</Grid.Resources>
<TabControl Style="{StaticResource ShowcaseTabControlStyle}">
<TabItem Header="Bound">
<TabItem.Resources>
<Style x:Key="BoundTreeViewItemStyle" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="Padding" Value="2" />
</Style>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="TreeView Unbound" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two TreeViews bound to two collections of the same type. Just try drag and drop some Items from left TreeView to right TreeView." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TreeView x:Name="LeftBoundTreeView"
Grid.Column="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
dd:DragDrop.SelectDroppedItems="True"
ItemContainerStyle="{StaticResource BoundTreeViewItemStyle}"
Loaded="LeftBoundTreeView_Loaded"
ItemsSource="{Binding Data.TreeCollection1}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<TextBlock Margin="2" Text="{Binding Caption}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<TreeView Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemContainerStyle="{StaticResource BoundTreeViewItemStyle}"
ItemsSource="{Binding Data.TreeCollection2}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<TextBlock Margin="2" Text="{Binding Caption}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left TreeView)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftBoundTreeView, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftBoundTreeView, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftBoundTreeView, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftBoundTreeView, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
<TabItem Header="Unbound">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top"
Style="{StaticResource SampleHeaderTextBlockStyle}"
Text="TreeView Unbound" />
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two TreeViews and unbound items (e.g. direct usage of TreeViewItem). Just try drag and drop some Items from left TreeView to right TreeView." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TreeView x:Name="LeftUnboundTreeView"
Grid.Column="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True">
<TreeViewItem Header="Root 1" IsExpanded="True">
<TreeViewItem Header="Item 10" />
<TreeViewItem Header="Item 20" />
<TreeViewItem Header="Item 30" />
<TreeViewItem Header="Item 40" />
<TreeViewItem Header="Item 50" />
</TreeViewItem>
<TreeViewItem Header="Root 2" IsExpanded="True">
<TreeViewItem Header="Item 20" />
<TreeViewItem Header="Item 21" />
<TreeViewItem Header="Item 22" />
</TreeViewItem>
<TreeViewItem Header="Root 3" />
</TreeView>
<TreeView Grid.Column="1"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True" />
</Grid>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left TreeView)" />
<CheckBox Margin="10 5"
Content="IsDragSource"
IsChecked="{Binding ElementName=LeftUnboundTreeView, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftUnboundTreeView, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftUnboundTreeView, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5"
Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftUnboundTreeView, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>
</TabControl>
</Grid>
</UserControl>

View File

@@ -0,0 +1,32 @@
using System.Windows.Controls;
using GongSolutions.Wpf.DragDrop.Utilities;
namespace Showcase.WPF.DragDrop.Views
{
/// <summary>
/// Interaction logic for TreeViewSamples.xaml
/// </summary>
public partial class TreeViewSamples : UserControl
{
public TreeViewSamples()
{
InitializeComponent();
}
private void LeftBoundTreeView_RequestBringIntoView(object sender, System.Windows.RequestBringIntoViewEventArgs e)
{
e.Handled = true;
}
private void LeftBoundTreeView_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
// Prevent automatic horizontal and vertical scrolling by subscribing to ScrollContentPresenter's RequestBringIntoView event and flag it as handled.
var p = (sender as TreeView).GetVisualDescendent<ScrollContentPresenter>();
if (p != null)
{
p.RequestBringIntoView -= this.LeftBoundTreeView_RequestBringIntoView;
p.RequestBringIntoView += this.LeftBoundTreeView_RequestBringIntoView;
}
}
}
}