mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-03 14:31:28 +08:00
项目结构调整
This commit is contained in:
6
Others/gong-wpf-dragdrop/src/Showcase/App.net45.config
Normal file
6
Others/gong-wpf-dragdrop/src/Showcase/App.net45.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
6
Others/gong-wpf-dragdrop/src/Showcase/App.net46.config
Normal file
6
Others/gong-wpf-dragdrop/src/Showcase/App.net46.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||
</startup>
|
||||
</configuration>
|
||||
253
Others/gong-wpf-dragdrop/src/Showcase/App.xaml
Normal file
253
Others/gong-wpf-dragdrop/src/Showcase/App.xaml
Normal file
@@ -0,0 +1,253 @@
|
||||
<Application x:Class="Showcase.WPF.DragDrop.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
StartupUri="MainWindow.xaml">
|
||||
|
||||
<Application.Resources>
|
||||
|
||||
<ResourceDictionary>
|
||||
|
||||
<SolidColorBrush x:Key="TabItemPanelBackgroundBrush" Color="Silver" />
|
||||
<SolidColorBrush x:Key="TabItemBackgroundIsSelectedBrush" Color="Gray" />
|
||||
<SolidColorBrush x:Key="TabItemBackgroundIsMouseOverBrush" Color="#A5A5A5" />
|
||||
<SolidColorBrush x:Key="TabItemForegroundIsSelectedBrush" Color="White" />
|
||||
<SolidColorBrush x:Key="TabItemSelectorBrush" Color="LawnGreen" />
|
||||
|
||||
<Style x:Key="GitHubIssueButtonStyle"
|
||||
x:Shared="False"
|
||||
TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Command" Value="{Binding OpenIssueCommand}" />
|
||||
<Setter Property="Content">
|
||||
<Setter.Value>
|
||||
<iconPacks:PackIconMaterial Width="24"
|
||||
Height="24"
|
||||
Kind="GithubCircle" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||
<Setter Property="Margin" Value="0 1 4 1" />
|
||||
<Setter Property="Padding" Value="1" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ButtonBase}">
|
||||
<Grid Background="Transparent">
|
||||
<Ellipse Fill="{TemplateBinding Background}" StrokeThickness="0" />
|
||||
<ContentPresenter x:Name="PART_ContentPresenter"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="#4078C0" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Foreground" Value="#315E95" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="GitHubPullRequestButtonStyle"
|
||||
x:Shared="False"
|
||||
BasedOn="{StaticResource GitHubIssueButtonStyle}"
|
||||
TargetType="{x:Type Button}">
|
||||
<Setter Property="Command" Value="{Binding OpenPullRequestCommand}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="OpenLinkButtonStyle"
|
||||
x:Shared="False"
|
||||
BasedOn="{StaticResource GitHubIssueButtonStyle}"
|
||||
TargetType="{x:Type Button}">
|
||||
<Setter Property="Command" Value="{Binding OpenLinkCommand}" />
|
||||
<Setter Property="Content">
|
||||
<Setter.Value>
|
||||
<iconPacks:PackIconFeatherIcons Width="20"
|
||||
Height="20"
|
||||
Kind="ExternalLink" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultTabItemStyle" TargetType="{x:Type TabItem}" />
|
||||
<Style x:Key="DefaultTabControlStyle" TargetType="{x:Type TabControl}">
|
||||
<Setter Property="Height" Value="100" />
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource DefaultTabItemStyle}" />
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="TabStripPlacement" Value="Top" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ShowcaseTabItemStyle" TargetType="{x:Type TabItem}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TabItem}">
|
||||
<Grid x:Name="PART_Grid"
|
||||
Margin="0"
|
||||
Background="{TemplateBinding Background}"
|
||||
SnapsToDevicePixels="True">
|
||||
<TextBlock Name="PART_Text"
|
||||
Margin="0"
|
||||
Padding="10"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{TemplateBinding Header}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="NoWrap" />
|
||||
<Rectangle x:Name="PART_Selector"
|
||||
Width="4"
|
||||
HorizontalAlignment="Left"
|
||||
Fill="{StaticResource TabItemSelectorBrush}"
|
||||
Visibility="Collapsed" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Trigger.Setters>
|
||||
<Setter Property="Background" Value="{StaticResource TabItemBackgroundIsSelectedBrush}" />
|
||||
<Setter TargetName="PART_Text" Property="Foreground" Value="{StaticResource TabItemForegroundIsSelectedBrush}" />
|
||||
<Setter TargetName="PART_Selector" Property="Visibility" Value="Visible" />
|
||||
</Trigger.Setters>
|
||||
</Trigger>
|
||||
<Trigger SourceName="PART_Grid" Property="IsMouseOver" Value="True">
|
||||
<Trigger.Setters>
|
||||
<Setter Property="Background" Value="{StaticResource TabItemBackgroundIsMouseOverBrush}" />
|
||||
</Trigger.Setters>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Width" Value="120" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ShowcaseTabControlStyle" TargetType="{x:Type TabControl}">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource ShowcaseTabItemStyle}" />
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="TabStripPlacement" Value="Left" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TabControl}">
|
||||
<DockPanel LastChildFill="True">
|
||||
<WrapPanel x:Name="HeaderPanel"
|
||||
Panel.ZIndex="1"
|
||||
Background="{StaticResource TabItemPanelBackgroundBrush}"
|
||||
DockPanel.Dock="Left"
|
||||
IsItemsHost="True"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
Orientation="Vertical" />
|
||||
<Border x:Name="ContentPanel"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained"
|
||||
KeyboardNavigation.TabIndex="2"
|
||||
KeyboardNavigation.TabNavigation="Local"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||
<ContentPresenter x:Name="PART_SelectedContentHost"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
ContentSource="SelectedContent"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</Border>
|
||||
</DockPanel>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="TabStripPlacement" Value="Top">
|
||||
<Setter TargetName="HeaderPanel" Property="DockPanel.Dock" Value="Top" />
|
||||
<Setter TargetName="HeaderPanel" Property="Orientation" Value="Horizontal" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultTextBlockStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SampleHeaderTextBlockStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Background" Value="Gainsboro" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Foreground" Value="Gray" />
|
||||
<Setter Property="Padding" Value="10" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="Padding" Value="2" />
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource DefaultListBoxItemStyle}" TargetType="{x:Type ListBoxItem}" />
|
||||
|
||||
<Style x:Key="DefaultListBoxStyle" TargetType="{x:Type ListBox}">
|
||||
<Setter Property="Height" Value="300" />
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource DefaultListBoxItemStyle}" />
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="SelectionMode" Value="Extended" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultItemsControl" TargetType="{x:Type ItemsControl}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="#FF888888" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Height" Value="300" />
|
||||
<Setter Property="Margin" Value="4" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultListViewItemStyle" TargetType="{x:Type ListViewItem}">
|
||||
<Setter Property="Padding" Value="2" />
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="{x:Type ListViewItem}" />
|
||||
|
||||
<Style x:Key="DefaultListViewStyle" TargetType="{x:Type ListView}">
|
||||
<Setter Property="Height" Value="300" />
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource DefaultListViewItemStyle}" />
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="SelectionMode" Value="Extended" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultTreeViewItemStyle" TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Margin="2" Text="{Binding}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Padding" Value="2" />
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource DefaultTreeViewItemStyle}" TargetType="{x:Type TreeViewItem}" />
|
||||
|
||||
<Style x:Key="DefaultTreeViewStyle" TargetType="{x:Type TreeView}">
|
||||
<Setter Property="Height" Value="300" />
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource DefaultTreeViewItemStyle}" />
|
||||
<Setter Property="Margin" Value="4" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DefaultDataGridStyle" TargetType="{x:Type DataGrid}">
|
||||
<Setter Property="Height" Value="300" />
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="Silver" />
|
||||
<Setter Property="Margin" Value="4" />
|
||||
<Setter Property="SelectionMode" Value="Extended" />
|
||||
<Setter Property="VerticalGridLinesBrush" Value="Silver" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
||||
</Application.Resources>
|
||||
|
||||
</Application>
|
||||
11
Others/gong-wpf-dragdrop/src/Showcase/App.xaml.cs
Normal file
11
Others/gong-wpf-dragdrop/src/Showcase/App.xaml.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Showcase.WPF.DragDrop
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.CustomControls
|
||||
{
|
||||
public class CustomListBox : ListBox
|
||||
{
|
||||
protected override DependencyObject GetContainerForItemOverride()
|
||||
{
|
||||
return new CustomListBoxItem();
|
||||
}
|
||||
|
||||
protected override bool IsItemItsOwnContainerOverride(object item)
|
||||
{
|
||||
return item is CustomListBoxItem;
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomListBoxItem : ListBoxItem
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
4
Others/gong-wpf-dragdrop/src/Showcase/FodyWeavers.xml
Normal file
4
Others/gong-wpf-dragdrop/src/Showcase/FodyWeavers.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<Costura DisableCompression="false" />
|
||||
</Weavers>
|
||||
111
Others/gong-wpf-dragdrop/src/Showcase/FodyWeavers.xsd
Normal file
111
Others/gong-wpf-dragdrop/src/Showcase/FodyWeavers.xsd
Normal file
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
|
||||
<xs:element name="Weavers">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="DisableCompression" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="DisableCleanup" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="ExcludeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="IncludeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="PreloadOrder" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="GenerateXsd" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
43
Others/gong-wpf-dragdrop/src/Showcase/MainWindow.xaml
Normal file
43
Others/gong-wpf-dragdrop/src/Showcase/MainWindow.xaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<Window x:Class="Showcase.WPF.DragDrop.MainWindow"
|
||||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
|
||||
xmlns:views="clr-namespace:Showcase.WPF.DragDrop.Views"
|
||||
Title="GongSolutions.WPF.DragDrop"
|
||||
Width="900"
|
||||
Height="600"
|
||||
d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
|
||||
<TabControl x:Name="MainTabControl" Style="{StaticResource ShowcaseTabControlStyle}">
|
||||
<TabItem Header="ListBox">
|
||||
<views:ListBoxSamples />
|
||||
</TabItem>
|
||||
<TabItem Header="ListView">
|
||||
<views:ListViewSamples />
|
||||
</TabItem>
|
||||
<TabItem Header="TreeView">
|
||||
<views:TreeViewSamples />
|
||||
</TabItem>
|
||||
<TabItem Header="DataGrid">
|
||||
<views:DataGridSamples />
|
||||
</TabItem>
|
||||
<TabItem Header="TabControl">
|
||||
<views:TabControlSamples />
|
||||
</TabItem>
|
||||
<TabItem Header="Mixed">
|
||||
<views:MixedSamples />
|
||||
</TabItem>
|
||||
<TabItem Header="Fixed #Issues">
|
||||
<views:Issues />
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
30
Others/gong-wpf-dragdrop/src/Showcase/MainWindow.xaml.cs
Normal file
30
Others/gong-wpf-dragdrop/src/Showcase/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
using Showcase.WPF.DragDrop.ViewModels;
|
||||
|
||||
namespace Showcase.WPF.DragDrop
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new MainViewModel();
|
||||
this.Loaded += MainWindowLoaded;
|
||||
}
|
||||
|
||||
private void MainWindowLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var appArgs = Environment.GetCommandLineArgs();
|
||||
if (appArgs.Length > 1 && appArgs[1] == "anotherOne")
|
||||
{
|
||||
this.MainTabControl.SelectedItem = MainTabControl.Items.OfType<TabItem>().FirstOrDefault(t => (string)t.Header == "Mixed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class ClonableItemModel : ItemModel, ICloneable
|
||||
{
|
||||
public ClonableItemModel()
|
||||
{
|
||||
}
|
||||
|
||||
public ClonableItemModel(int itemIndex)
|
||||
: base(itemIndex)
|
||||
{
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var clonableItemModel = new ClonableItemModel();
|
||||
clonableItemModel.BindableDoubleValue = this.BindableDoubleValue;
|
||||
clonableItemModel.SubItemCollection.Clear();
|
||||
foreach (var subItem in this.SubItemCollection)
|
||||
{
|
||||
clonableItemModel.SubItemCollection.Add(subItem);
|
||||
}
|
||||
clonableItemModel.SelectedSubItem = this.SelectedSubItem;
|
||||
clonableItemModel.Index = this.Index;
|
||||
clonableItemModel.Caption = $"Cloned Item {this.Index}";
|
||||
return clonableItemModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Faker;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class DataGridRowModel
|
||||
{
|
||||
public string Name { get; set; } = Faker.Name.FullName(NameFormats.Standard);
|
||||
|
||||
public string StreetName { get; set; } = Faker.Address.StreetName();
|
||||
|
||||
public string City { get; set; } = Faker.Address.City();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class DragAdornerTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
public DataTemplate TemplateEven { get; set; }
|
||||
|
||||
public DataTemplate TemplateOdd { get; set; }
|
||||
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
var itemModel = item as ItemModel;
|
||||
return itemModel != null && (itemModel.Index & 0x01) == 0 ? TemplateEven : TemplateOdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom drop handler which is used for the grouping example.
|
||||
/// </summary>
|
||||
public class GroupedDropHandler : IDropTarget
|
||||
{
|
||||
public void DragOver(IDropInfo dropInfo)
|
||||
{
|
||||
// Call default DragOver method, cause most stuff should work by default
|
||||
GongSolutions.Wpf.DragDrop.DragDrop.DefaultDropHandler.DragOver(dropInfo);
|
||||
if (dropInfo.TargetGroup == null)
|
||||
{
|
||||
dropInfo.Effects = System.Windows.DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
public void Drop(IDropInfo dropInfo)
|
||||
{
|
||||
// The default drop handler don't know how to set an item's group. You need to explicitly set the group on the dropped item like this.
|
||||
GongSolutions.Wpf.DragDrop.DragDrop.DefaultDropHandler.Drop(dropInfo);
|
||||
|
||||
// Now extract the dragged group items and set the new group (target)
|
||||
var data = DefaultDropHandler.ExtractData(dropInfo.Data).OfType<GroupedItem>().ToList();
|
||||
foreach (var groupedItem in data)
|
||||
{
|
||||
groupedItem.Group = dropInfo.TargetGroup.Name.ToString();
|
||||
}
|
||||
|
||||
// Changing group data at runtime isn't handled well: force a refresh on the collection view.
|
||||
if (dropInfo.TargetCollection is ICollectionView)
|
||||
{
|
||||
((ICollectionView)dropInfo.TargetCollection).Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Others/gong-wpf-dragdrop/src/Showcase/Models/GroupedItem.cs
Normal file
52
Others/gong-wpf-dragdrop/src/Showcase/Models/GroupedItem.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class GroupedItem : INotifyPropertyChanged
|
||||
{
|
||||
private string _caption;
|
||||
private string _group;
|
||||
|
||||
public GroupedItem(int group, int item)
|
||||
{
|
||||
this.Caption = $"Item {item} from Group {group}";
|
||||
this._group = $"Group {group}";
|
||||
}
|
||||
|
||||
public string Caption
|
||||
{
|
||||
get { return _caption; }
|
||||
set
|
||||
{
|
||||
if (value == _caption) return;
|
||||
_caption = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string Group
|
||||
|
||||
{
|
||||
get { return _group; }
|
||||
set
|
||||
{
|
||||
if (value == _group)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_group = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
155
Others/gong-wpf-dragdrop/src/Showcase/Models/ItemModel.cs
Normal file
155
Others/gong-wpf-dragdrop/src/Showcase/Models/ItemModel.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Input;
|
||||
using JetBrains.Annotations;
|
||||
using Showcase.WPF.DragDrop.ViewModels;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class ItemModel : INotifyPropertyChanged
|
||||
{
|
||||
private double _bindableDoubleValue;
|
||||
private string _selectedSubItem;
|
||||
|
||||
public ItemModel()
|
||||
{
|
||||
this.BindableDoubleValue = Faker.RandomNumber.Next(0, 100);
|
||||
for (int i = 0; i < Faker.RandomNumber.Next(2, 20); i++)
|
||||
{
|
||||
SubItemCollection.Add(new SubItemModel($"Sub item {i}"));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemModel(int itemIndex)
|
||||
: this()
|
||||
{
|
||||
this.Index = itemIndex;
|
||||
this.Caption = $"Item {itemIndex}";
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
|
||||
public string Caption { get; set; }
|
||||
|
||||
public ObservableCollection<SubItemModel> SubItemCollection { get; set; } = new ObservableCollection<SubItemModel>();
|
||||
|
||||
public string SelectedSubItem
|
||||
{
|
||||
get { return _selectedSubItem; }
|
||||
set
|
||||
{
|
||||
if (value == _selectedSubItem) return;
|
||||
_selectedSubItem = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public double BindableDoubleValue
|
||||
{
|
||||
get { return _bindableDoubleValue; }
|
||||
set
|
||||
{
|
||||
if (value.Equals(_bindableDoubleValue)) return;
|
||||
_bindableDoubleValue = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Caption;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public class SubItemModel : INotifyPropertyChanged
|
||||
{
|
||||
private string _bindableValue;
|
||||
private bool _bindableOptionA;
|
||||
private bool _bindableOptionB;
|
||||
|
||||
public SubItemModel(string caption)
|
||||
{
|
||||
this.Caption = caption;
|
||||
this.ButtonTestCommand = new SimpleCommand(o => { this.BindableValue = $"Button clicked at {DateTime.UtcNow.ToLocalTime()}"; });
|
||||
}
|
||||
|
||||
public string Caption { get; set; }
|
||||
|
||||
public ICommand ButtonTestCommand { get; set; }
|
||||
|
||||
public string BindableValue
|
||||
{
|
||||
get { return _bindableValue; }
|
||||
set
|
||||
{
|
||||
if (value == _bindableValue) return;
|
||||
_bindableValue = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool BindableOptionA
|
||||
{
|
||||
get { return _bindableOptionA; }
|
||||
set
|
||||
{
|
||||
if (value == _bindableOptionA) return;
|
||||
_bindableOptionA = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool BindableOptionB
|
||||
{
|
||||
get { return _bindableOptionB; }
|
||||
set
|
||||
{
|
||||
if (value == _bindableOptionB) return;
|
||||
_bindableOptionB = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Caption;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class SerializableItemModel
|
||||
{
|
||||
public SerializableItemModel(int itemIndex)
|
||||
{
|
||||
this.Index = itemIndex;
|
||||
this.Caption = $"{itemIndex}. Item";
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
|
||||
public string Caption { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Caption;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class ListBoxCustomDropHandler : DefaultDropHandler
|
||||
{
|
||||
public override void DragOver(IDropInfo dropInfo)
|
||||
{
|
||||
if (dropInfo.VisualTarget == dropInfo.DragInfo.VisualSource)
|
||||
{
|
||||
dropInfo.NotHandled = dropInfo.VisualTarget == dropInfo.DragInfo.VisualSource;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.DragOver(dropInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Drop(IDropInfo dropInfo)
|
||||
{
|
||||
if (dropInfo.VisualTarget == dropInfo.DragInfo.VisualSource)
|
||||
{
|
||||
dropInfo.NotHandled = dropInfo.VisualTarget == dropInfo.DragInfo.VisualSource;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Drop(dropInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class NestedDropHandler : IDropTarget
|
||||
{
|
||||
public void DragOver(IDropInfo dropInfo)
|
||||
{
|
||||
if (dropInfo.TargetItem?.ToString().StartsWith("Root", StringComparison.OrdinalIgnoreCase) == true)
|
||||
{
|
||||
dropInfo.Effects = DragDropEffects.Move;
|
||||
dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
|
||||
}
|
||||
}
|
||||
|
||||
public void Drop(IDropInfo dropInfo)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
105
Others/gong-wpf-dragdrop/src/Showcase/Models/SampleData.cs
Normal file
105
Others/gong-wpf-dragdrop/src/Showcase/Models/SampleData.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Data;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class SampleData
|
||||
{
|
||||
public SampleData()
|
||||
{
|
||||
for (var n = 0; n < 50; ++n)
|
||||
{
|
||||
this.SerializableCollection1.Add(new SerializableItemModel(n + 1));
|
||||
this.Collection1.Add(new ItemModel(n + 1));
|
||||
this.FilterCollection1.Add(new ItemModel(n + 1));
|
||||
this.ClonableCollection1.Add(new ClonableItemModel(n + 1));
|
||||
this.DataGridCollection1.Add(new DataGridRowModel());
|
||||
}
|
||||
for (var n = 0; n < 10; ++n)
|
||||
{
|
||||
this.Collection4.Add(new ItemModel() { Caption = $"Model {n + 1}" });
|
||||
}
|
||||
|
||||
for (var g = 0; g < 4; ++g)
|
||||
{
|
||||
for (var i = 0; i < ((g % 2) == 0 ? 4 : 2); ++i)
|
||||
{
|
||||
this.GroupedCollection.Add(new GroupedItem(g, i));
|
||||
}
|
||||
}
|
||||
|
||||
this.GroupedItemsCollectionViewSource = CollectionViewSource.GetDefaultView(this.GroupedCollection);
|
||||
this.GroupedItemsCollectionViewSource.GroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = nameof(GroupedItem.Group) });
|
||||
|
||||
for (int r = 1; r <= 6; r++)
|
||||
{
|
||||
var root = new TreeNode($"Root {r}");
|
||||
for (var i = 0; i < ((r % 2) == 0 ? 8 : 3); ++i)
|
||||
{
|
||||
root.Children.Add(new TreeNode($"Item {i + 10 * r}"));
|
||||
}
|
||||
this.TreeCollection1.Add(root);
|
||||
if (r == 2)
|
||||
{
|
||||
root.IsExpanded = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
this.TabItemCollection1.Add(new TabItemModel(i + 1));
|
||||
}
|
||||
this.TabItemCollection2.Add(new TabItemModel(1));
|
||||
}
|
||||
|
||||
public ObservableCollection<SerializableItemModel> SerializableCollection1 { get; set; } = new ObservableCollection<SerializableItemModel>();
|
||||
|
||||
public ObservableCollection<SerializableItemModel> SerializableCollection2 { get; set; } = new ObservableCollection<SerializableItemModel>();
|
||||
|
||||
public SerializableDragHandler SerializableDragHandler { get; set; } = new SerializableDragHandler();
|
||||
|
||||
public SerializableDropHandler SerializableDropHandler { get; set; } = new SerializableDropHandler();
|
||||
|
||||
public ObservableCollection<ItemModel> Collection1 { get; set; } = new ObservableCollection<ItemModel>();
|
||||
|
||||
public ObservableCollection<ItemModel> Collection2 { get; set; } = new ObservableCollection<ItemModel>();
|
||||
|
||||
public ObservableCollection<ItemModel> Collection3 { get; set; } = new ObservableCollection<ItemModel>();
|
||||
|
||||
public ObservableCollection<ItemModel> Collection4 { get; set; } = new ObservableCollection<ItemModel>();
|
||||
|
||||
public ObservableCollection<ClonableItemModel> ClonableCollection1 { get; set; } = new ObservableCollection<ClonableItemModel>();
|
||||
|
||||
public ObservableCollection<ClonableItemModel> ClonableCollection2 { get; set; } = new ObservableCollection<ClonableItemModel>();
|
||||
|
||||
public ObservableCollection<ItemModel> FilterCollection1 { get; set; } = new ObservableCollection<ItemModel>();
|
||||
|
||||
public ObservableCollection<ItemModel> FilterCollection2 { get; set; } = new ObservableCollection<ItemModel>();
|
||||
|
||||
public ObservableCollection<TreeNode> TreeCollection1 { get; set; } = new ObservableCollection<TreeNode>();
|
||||
|
||||
public ObservableCollection<TreeNode> TreeCollection2 { get; set; } = new ObservableCollection<TreeNode>();
|
||||
|
||||
public GroupedDropHandler GroupedDropHandler { get; set; } = new GroupedDropHandler();
|
||||
|
||||
public ObservableCollection<GroupedItem> GroupedCollection { get; set; } = new ObservableCollection<GroupedItem>();
|
||||
|
||||
public ICollectionView GroupedItemsCollectionViewSource { get; }
|
||||
|
||||
public ObservableCollection<DataGridRowModel> DataGridCollection1 { get; set; } = new ObservableCollection<DataGridRowModel>();
|
||||
|
||||
public ObservableCollection<DataGridRowModel> DataGridCollection2 { get; set; } = new ObservableCollection<DataGridRowModel>();
|
||||
|
||||
public ObservableCollection<TabItemModel> TabItemCollection1 { get; set; } = new ObservableCollection<TabItemModel>();
|
||||
|
||||
public ObservableCollection<TabItemModel> TabItemCollection2 { get; set; } = new ObservableCollection<TabItemModel>();
|
||||
|
||||
public TextBoxCustomDropHandler TextBoxCustomDropHandler { get; set; } = new TextBoxCustomDropHandler();
|
||||
|
||||
public ListBoxCustomDropHandler ListBoxCustomDropHandler { get; set; } = new ListBoxCustomDropHandler();
|
||||
|
||||
public IDropTarget NestedDropHandler { get; set; } = new NestedDropHandler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
using GongSolutions.Wpf.DragDrop.Utilities;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
[Serializable]
|
||||
public class SerializableWrapper
|
||||
{
|
||||
public IEnumerable<object> Items { get; set; }
|
||||
|
||||
public DragDropKeyStates DragDropCopyKeyState { get; set; }
|
||||
}
|
||||
|
||||
public class SerializableDragHandler : IDragSource
|
||||
{
|
||||
private bool alreadyDropped = false;
|
||||
|
||||
public void StartDrag(IDragInfo dragInfo)
|
||||
{
|
||||
alreadyDropped = false;
|
||||
var items = dragInfo.SourceItems.OfType<object>().ToList();
|
||||
var wrapper = new SerializableWrapper()
|
||||
{
|
||||
Items = items,
|
||||
DragDropCopyKeyState = DragDropKeyStates.ControlKey //dragInfo.DragDropCopyKeyState
|
||||
};
|
||||
dragInfo.Data = wrapper;
|
||||
dragInfo.DataFormat = DataFormats.GetDataFormat(DataFormats.Serializable);
|
||||
dragInfo.Effects = dragInfo.Data != null ? DragDropEffects.Copy | DragDropEffects.Move : DragDropEffects.None;
|
||||
}
|
||||
|
||||
public bool CanStartDrag(IDragInfo dragInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dropped(IDropInfo dropInfo)
|
||||
{
|
||||
alreadyDropped = true;
|
||||
}
|
||||
|
||||
public void DragDropOperationFinished(DragDropEffects operationResult, IDragInfo dragInfo)
|
||||
{
|
||||
if (alreadyDropped || dragInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// the drag operation has finished on another app
|
||||
if (operationResult != DragDropEffects.None)
|
||||
{
|
||||
if (operationResult.HasFlag(DragDropEffects.Move))
|
||||
{
|
||||
var sourceList = dragInfo.SourceCollection.TryGetList();
|
||||
var items = dragInfo.SourceItems.OfType<object>().ToList();
|
||||
if (sourceList != null)
|
||||
{
|
||||
foreach (var o in items)
|
||||
{
|
||||
sourceList.Remove(o);
|
||||
}
|
||||
}
|
||||
alreadyDropped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DragCancelled()
|
||||
{
|
||||
}
|
||||
|
||||
public bool TryCatchOccurredException(Exception exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
using GongSolutions.Wpf.DragDrop.Utilities;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class SerializableDropHandler : IDropTarget
|
||||
{
|
||||
public void DragOver(IDropInfo dropInfo)
|
||||
{
|
||||
var wrapper = GetSerializableWrapper(dropInfo);
|
||||
if (wrapper != null && dropInfo.TargetCollection != null)
|
||||
{
|
||||
dropInfo.Effects = ShouldCopyData(dropInfo, wrapper.DragDropCopyKeyState) ? DragDropEffects.Copy : DragDropEffects.Move;
|
||||
dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
|
||||
}
|
||||
}
|
||||
|
||||
public void Drop(IDropInfo dropInfo)
|
||||
{
|
||||
var wrapper = GetSerializableWrapper(dropInfo);
|
||||
if (wrapper != null && dropInfo.TargetCollection != null)
|
||||
{
|
||||
// at this point the drag info can be null, cause the other app doesn't know it
|
||||
var insertIndex = dropInfo.InsertIndex != dropInfo.UnfilteredInsertIndex ? dropInfo.UnfilteredInsertIndex : dropInfo.InsertIndex;
|
||||
var destinationList = dropInfo.TargetCollection.TryGetList();
|
||||
var copyData = ShouldCopyData(dropInfo, wrapper.DragDropCopyKeyState);
|
||||
|
||||
if (!copyData)
|
||||
{
|
||||
var sourceList = dropInfo.DragInfo?.SourceCollection?.TryGetList();
|
||||
if (sourceList != null)
|
||||
{
|
||||
foreach (var o in wrapper.Items)
|
||||
{
|
||||
var index = sourceList.IndexOf(o);
|
||||
if (index != -1)
|
||||
{
|
||||
sourceList.RemoveAt(index);
|
||||
// so, is the source list the destination list too ?
|
||||
if (destinationList != null && Equals(sourceList, destinationList) && index < insertIndex)
|
||||
{
|
||||
--insertIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (destinationList != null)
|
||||
{
|
||||
// check for cloning
|
||||
var cloneData = dropInfo.Effects.HasFlag(DragDropEffects.Copy)
|
||||
|| dropInfo.Effects.HasFlag(DragDropEffects.Link);
|
||||
foreach (var o in wrapper.Items)
|
||||
{
|
||||
var obj2Insert = o;
|
||||
if (cloneData)
|
||||
{
|
||||
var cloneable = o as ICloneable;
|
||||
if (cloneable != null)
|
||||
{
|
||||
obj2Insert = cloneable.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
destinationList.Insert(insertIndex++, obj2Insert);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static SerializableWrapper GetSerializableWrapper(IDropInfo dropInfo)
|
||||
{
|
||||
var data = dropInfo.Data;
|
||||
|
||||
var dataObject = data as DataObject;
|
||||
if (dataObject != null)
|
||||
{
|
||||
var dataFormat = DataFormats.GetDataFormat(DataFormats.Serializable);
|
||||
data = dataObject.GetDataPresent(dataFormat.Name) ? dataObject.GetData(dataFormat.Name) : data;
|
||||
}
|
||||
|
||||
var wrapper = data as SerializableWrapper;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private static bool ShouldCopyData(IDropInfo dropInfo, DragDropKeyStates dragDropCopyKeyState)
|
||||
{
|
||||
// default should always the move action/effect
|
||||
if (dropInfo == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var copyData = ((dragDropCopyKeyState != default(DragDropKeyStates)) && dropInfo.KeyStates.HasFlag(dragDropCopyKeyState))
|
||||
|| dragDropCopyKeyState.HasFlag(DragDropKeyStates.LeftMouseButton);
|
||||
return copyData;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Others/gong-wpf-dragdrop/src/Showcase/Models/TabItemModel.cs
Normal file
15
Others/gong-wpf-dragdrop/src/Showcase/Models/TabItemModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class TabItemModel
|
||||
{
|
||||
public TabItemModel(int itemIndex)
|
||||
{
|
||||
this.Header = $"TabItem {itemIndex}";
|
||||
this.Content = Faker.Lorem.Paragraph();
|
||||
}
|
||||
|
||||
public string Header { get; set; }
|
||||
|
||||
public string Content { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using GongSolutions.Wpf.DragDrop;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class TextBoxCustomDropHandler : IDropTarget
|
||||
{
|
||||
public void DragOver(IDropInfo dropInfo)
|
||||
{
|
||||
dropInfo.DropTargetAdorner = typeof(DropTargetHighlightAdorner);
|
||||
dropInfo.Effects = DragDropEffects.Move;
|
||||
}
|
||||
|
||||
public void Drop(IDropInfo dropInfo)
|
||||
{
|
||||
var dataAsList = DefaultDropHandler.ExtractData(dropInfo.Data);
|
||||
((TextBox)dropInfo.VisualTarget).Text = string.Join(", ", dataAsList.OfType<object>().ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public class DropTargetHighlightAdorner : DropTargetAdorner
|
||||
{
|
||||
private readonly Pen _pen;
|
||||
private readonly Brush _brush;
|
||||
|
||||
public DropTargetHighlightAdorner(UIElement adornedElement, DropInfo dropInfo)
|
||||
: base(adornedElement, dropInfo)
|
||||
{
|
||||
_pen = new Pen(Brushes.Tomato, 2);
|
||||
_pen.Freeze();
|
||||
_brush = new SolidColorBrush(Colors.Coral) { Opacity = 0.2 };
|
||||
this._brush.Freeze();
|
||||
|
||||
this.SetValue(SnapsToDevicePixelsProperty, true);
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
var visualTarget = this.DropInfo.VisualTarget;
|
||||
if (visualTarget != null)
|
||||
{
|
||||
var translatePoint = visualTarget.TranslatePoint(new Point(), this.AdornedElement);
|
||||
translatePoint.Offset(1, 1);
|
||||
var bounds = new Rect(translatePoint,
|
||||
new Size(visualTarget.RenderSize.Width - 2, visualTarget.RenderSize.Height - 2));
|
||||
drawingContext.DrawRectangle(_brush, _pen, bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
89
Others/gong-wpf-dragdrop/src/Showcase/Models/TreeNode.cs
Normal file
89
Others/gong-wpf-dragdrop/src/Showcase/Models/TreeNode.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.Models
|
||||
{
|
||||
public class TreeNode : INotifyPropertyChanged, ICloneable
|
||||
{
|
||||
private string _caption;
|
||||
private ObservableCollection<TreeNode> _children;
|
||||
private bool _isCloned;
|
||||
private bool _isExpanded;
|
||||
|
||||
public TreeNode(string caption)
|
||||
{
|
||||
this.Caption = caption;
|
||||
this.Children = new ObservableCollection<TreeNode>();
|
||||
}
|
||||
|
||||
public string Caption
|
||||
{
|
||||
get { return _caption; }
|
||||
set
|
||||
{
|
||||
if (value == _caption) return;
|
||||
_caption = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<TreeNode> Children
|
||||
{
|
||||
get { return _children; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _children)) return;
|
||||
_children = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCloned
|
||||
{
|
||||
get { return _isCloned; }
|
||||
set
|
||||
{
|
||||
if (value == _isCloned) return;
|
||||
_isCloned = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get { return _isExpanded; }
|
||||
set
|
||||
{
|
||||
if (value == _isExpanded) return;
|
||||
_isExpanded = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Caption;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var treeNode = new TreeNode(this.Caption) { IsCloned = true };
|
||||
foreach (var child in this.Children)
|
||||
{
|
||||
treeNode.Children.Add((TreeNode)child.Clone());
|
||||
}
|
||||
return treeNode;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<!-- Project properties -->
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net45;net46;netcoreapp3.0</TargetFrameworks>
|
||||
<AssemblyName>Showcase.WPF.DragDrop</AssemblyName>
|
||||
<RootNamespace>Showcase.WPF.DragDrop</RootNamespace>
|
||||
<DisableFody Condition="'$(Configuration)' == 'Debug' or '$(TargetFramework)' == 'netcoreapp3.0'">true</DisableFody>
|
||||
<Description>Showcase application for GongSolutions.WPF.DragDrop</Description>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<NoWarn>SA1652</NoWarn>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<!-- reference includes -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fody" Version="6.0.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Costura.Fody" Version="4.*" PrivateAssets="All" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.0.0-alpha*" />
|
||||
<PackageReference Include="Faker.Net" Version="1.*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.manifest" />
|
||||
<None Remove="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
|
||||
<AppConfigWithTargetPath Include="App.$(TargetFramework).config">
|
||||
<TargetPath>$(AssemblyName).config</TargetPath>
|
||||
</AppConfigWithTargetPath>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GongSolutions.WPF.DragDrop\GongSolutions.WPF.DragDrop.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,132 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using Showcase.WPF.DragDrop.Models;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.ViewModels
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
public class ListMember : List<SubMember>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class SubMember
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
private SampleData _data;
|
||||
private ICommand _openIssueCommand;
|
||||
private ICommand _openPullRequestCommand;
|
||||
private ICommand _openLinkCommand;
|
||||
private ICommand _filterCollectionCommand;
|
||||
|
||||
public ObservableCollection<ListMember> Members { get; set; } = new ObservableCollection<ListMember>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MainViewModel class.
|
||||
/// </summary>
|
||||
public MainViewModel()
|
||||
{
|
||||
////if (IsInDesignMode)
|
||||
////{
|
||||
//// // Code runs in Blend --> create design time data.
|
||||
////}
|
||||
////else
|
||||
////{
|
||||
//// // Code runs "for real"
|
||||
////}
|
||||
|
||||
var listMember = new ListMember() { Name = "Item 1" };
|
||||
Members.Add(listMember);
|
||||
|
||||
listMember = new ListMember() { Name = "Item 2 with SubItems" };
|
||||
listMember.Add(new SubMember() { Name = "SubItem 1" });
|
||||
listMember.Add(new SubMember() { Name = "SubItem 2" });
|
||||
Members.Add(listMember);
|
||||
|
||||
listMember = new ListMember() { Name = "Item 3" };
|
||||
Members.Add(listMember);
|
||||
|
||||
this.Data = new SampleData();
|
||||
this.OpenIssueCommand = new SimpleCommand(issue => { Process.Start($"https://github.com/punker76/gong-wpf-dragdrop/issues/{issue}"); });
|
||||
this.OpenPullRequestCommand = new SimpleCommand(pr => { Process.Start($"https://github.com/punker76/gong-wpf-dragdrop/pull/{pr}"); });
|
||||
this.OpenLinkCommand = new SimpleCommand(link => { Process.Start(link.ToString()); });
|
||||
this.FilterCollectionCommand = new SimpleCommand(isChecked =>
|
||||
{
|
||||
var coll = Data.FilterCollection1;
|
||||
var collView = CollectionViewSource.GetDefaultView(coll);
|
||||
collView.Filter += o =>
|
||||
{
|
||||
if (!(isChecked as bool?).GetValueOrDefault())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
var itemModel = (ItemModel)o;
|
||||
var number = itemModel.Index;
|
||||
return (number & 0x01) == 0;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public SampleData Data
|
||||
{
|
||||
get { return _data; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _data)) return;
|
||||
_data = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenIssueCommand
|
||||
{
|
||||
get { return _openIssueCommand; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _openIssueCommand)) return;
|
||||
_openIssueCommand = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenPullRequestCommand
|
||||
{
|
||||
get { return _openPullRequestCommand; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _openPullRequestCommand)) return;
|
||||
_openPullRequestCommand = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenLinkCommand
|
||||
{
|
||||
get { return _openLinkCommand; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _openLinkCommand)) return;
|
||||
_openLinkCommand = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand FilterCollectionCommand
|
||||
{
|
||||
get { return _filterCollectionCommand; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _filterCollectionCommand)) return;
|
||||
_filterCollectionCommand = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.ViewModels
|
||||
{
|
||||
public class SimpleCommand : ICommand
|
||||
{
|
||||
public SimpleCommand(Action<object> execute = null, Predicate<object> canExecute = null)
|
||||
{
|
||||
this.CanExecuteDelegate = canExecute;
|
||||
this.ExecuteDelegate = execute;
|
||||
}
|
||||
|
||||
public Predicate<object> CanExecuteDelegate { get; set; }
|
||||
|
||||
public Action<object> ExecuteDelegate { get; set; }
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
var canExecute = this.CanExecuteDelegate;
|
||||
return canExecute == null || canExecute(parameter);
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
this.ExecuteDelegate?.Invoke(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.ViewModels
|
||||
{
|
||||
public class ViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
1095
Others/gong-wpf-dragdrop/src/Showcase/Views/Issues.xaml
Normal file
1095
Others/gong-wpf-dragdrop/src/Showcase/Views/Issues.xaml
Normal file
File diff suppressed because it is too large
Load Diff
15
Others/gong-wpf-dragdrop/src/Showcase/Views/Issues.xaml.cs
Normal file
15
Others/gong-wpf-dragdrop/src/Showcase/Views/Issues.xaml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
460
Others/gong-wpf-dragdrop/src/Showcase/Views/ListBoxSamples.xaml
Normal file
460
Others/gong-wpf-dragdrop/src/Showcase/Views/ListBoxSamples.xaml
Normal 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="RightToLeft" 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="-1"." />
|
||||
<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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
223
Others/gong-wpf-dragdrop/src/Showcase/Views/ListViewSamples.xaml
Normal file
223
Others/gong-wpf-dragdrop/src/Showcase/Views/ListViewSamples.xaml
Normal 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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
603
Others/gong-wpf-dragdrop/src/Showcase/Views/MixedSamples.xaml
Normal file
603
Others/gong-wpf-dragdrop/src/Showcase/Views/MixedSamples.xaml
Normal 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>
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
146
Others/gong-wpf-dragdrop/src/Showcase/Views/TreeViewSamples.xaml
Normal file
146
Others/gong-wpf-dragdrop/src/Showcase/Views/TreeViewSamples.xaml
Normal 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>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
Others/gong-wpf-dragdrop/src/Showcase/app.manifest
Normal file
56
Others/gong-wpf-dragdrop/src/Showcase/app.manifest
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<asmv1:assembly manifestVersion="1.0"
|
||||
xmlns="urn:schemas-microsoft-com:asm.v1"
|
||||
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
|
||||
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
|
||||
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<assemblyIdentity version="1.0.0.0" name="Showcase.WPF.DragDrop"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker"
|
||||
uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of all Windows versions that this application is designed to work with. Windows will automatically select the most compatible environment.-->
|
||||
<!--The ID below indicates application support for Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
<!--The ID below indicates application support for Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
<!--The ID below indicates application support for Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!--The ID below indicates application support for Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!--The ID below indicates application support for Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<!-- The combination of below two tags have the following effect :
|
||||
1) Per-Monitor for >= RS1 (Windows 10 Anniversary Update)
|
||||
2) System < RS1 -->
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor</dpiAwareness>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*" />
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</asmv1:assembly>
|
||||
Reference in New Issue
Block a user