Skip to content

Commit

Permalink
Issue #85 sample
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Aug 29, 2016
1 parent d2ef985 commit 2ed1258
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 15 deletions.
14 changes: 5 additions & 9 deletions src/Showcase.WPF.DragDrop.NET45/Models/SampleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,12 @@ public SampleData()
public GroupedDropHandler GroupedDropHandler { get; set; } = new GroupedDropHandler();
public ObservableCollection<GroupedItem> GroupedCollection { get; set; } = new ObservableCollection<GroupedItem>();

public ObservableCollection<DataGridRowModel> DataGridCollection1 { get; set; } =
new ObservableCollection<DataGridRowModel>();
public ObservableCollection<DataGridRowModel> DataGridCollection1 { get; set; } = new ObservableCollection<DataGridRowModel>();
public ObservableCollection<DataGridRowModel> DataGridCollection2 { 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 ObservableCollection<TabItemModel> TabItemCollection1 { get; set; } =
new ObservableCollection<TabItemModel>();

public ObservableCollection<TabItemModel> TabItemCollection2 { get; set; } =
new ObservableCollection<TabItemModel>();
public TextBoxCustomDropHandler TextBoxCustomDropHandler { get; set; } = new TextBoxCustomDropHandler();
}
}
21 changes: 21 additions & 0 deletions src/Showcase.WPF.DragDrop.NET45/Models/TextBoxCustomDropHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using GongSolutions.Wpf.DragDrop;

namespace Showcase.WPF.DragDrop.Models
{
public class TextBoxCustomDropHandler : IDropTarget
{
public void DragOver(IDropInfo dropInfo)
{
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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="Models\ItemModel.cs" />
<Compile Include="Models\SampleData.cs" />
<Compile Include="Models\TabItemModel.cs" />
<Compile Include="Models\TextBoxCustomDropHandler.cs" />
<Compile Include="Models\TreeNode.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
Expand Down
40 changes: 34 additions & 6 deletions src/Showcase.WPF.DragDrop.NET45/Views/Issues.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@
</TabItem>

<TabItem Header="#30">
<TabItem.Resources>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<Grid DockPanel.Dock="Top">
<TextBlock Text="No support for derived item container classes" Style="{StaticResource SampleHeaderTextBlockStyle}" />
Expand Down Expand Up @@ -344,8 +342,6 @@
</TabItem>

<TabItem Header="#73">
<TabItem.Resources>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<Grid DockPanel.Dock="Top">
<TextBlock Text="Crash on click inside empty ItemsControl" Style="{StaticResource SampleHeaderTextBlockStyle}" />
Expand Down Expand Up @@ -399,8 +395,6 @@
</TabItem>

<TabItem Header="#64">
<TabItem.Resources>
</TabItem.Resources>
<DockPanel LastChildFill="True">
<Grid DockPanel.Dock="Top">
<TextBlock Text="ItemsControl itself doesn't work" Style="{StaticResource SampleHeaderTextBlockStyle}" />
Expand Down Expand Up @@ -481,6 +475,40 @@
</DockPanel>
</TabItem>

<TabItem Header="#85">
<DockPanel LastChildFill="True">
<Grid DockPanel.Dock="Top">
<TextBlock Text="Drop to Control which is not an ItemsControl" Style="{StaticResource SampleHeaderTextBlockStyle}" />
<Button CommandParameter="85" ToolTip="Open #85 on Github" Style="{StaticResource GitHubIssueButtonStyle}" />
</Grid>
<ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}"
Text="You can drag and drop items to any other Control with a custom DropHandler." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0"
x:Name="LeftIssue85ListBox"
ItemsSource="{Binding Data.Collection1}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True" />
<Grid Grid.Column="1">
<TextBox Text="Drop any item here..."
IsReadOnly="True"
Height="30"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.DropHandler="{Binding Data.TextBoxCustomDropHandler}" />
</Grid>
</Grid>
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>

</TabControl>

</Grid>
Expand Down

0 comments on commit 2ed1258

Please sign in to comment.