Skip to content

Commit

Permalink
Issue #73 sample
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Aug 26, 2016
1 parent b5cd53f commit d3580e1
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Showcase.WPF.DragDrop.NET45/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
</Setter>
</Style>

<Style x:Key="GitHubPullRequestButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource GitHubIssueButtonStyle}" x:Shared="False">
<Setter Property="Command" Value="{Binding OpenPullRequestCommand}" />
</Style>

<Style x:Key="DefaultTabItemStyle" TargetType="{x:Type TabItem}" />
<Style x:Key="DefaultTabControlStyle" TargetType="{x:Type TabControl}">
<Setter Property="TabStripPlacement" Value="Top" />
Expand Down Expand Up @@ -175,6 +179,14 @@
<Setter Property="ItemContainerStyle" Value="{StaticResource DefaultListBoxItemStyle}" />
</Style>

<Style x:Key="DefaultItemsControl" TargetType="{x:Type ItemsControl}">
<Setter Property="Margin" Value="4" />
<Setter Property="Height" Value="300" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="#FF888888" />
<Setter Property="Background" Value="Transparent" />
</Style>

<Style x:Key="DefaultListViewItemStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="Padding" Value="2" />
</Style>
Expand Down
1 change: 1 addition & 0 deletions src/Showcase.WPF.DragDrop.NET45/Models/SampleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public SampleData()

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<TreeNode> TreeCollection1 { get; set; } = new ObservableCollection<TreeNode>();
public ObservableCollection<TreeNode> TreeCollection2 { get; set; } = new ObservableCollection<TreeNode>();
Expand Down
13 changes: 13 additions & 0 deletions src/Showcase.WPF.DragDrop.NET45/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class MainViewModel : ViewModelBase
{
private SampleData _data;
private ICommand _openIssueCommand;
private ICommand _openPullRequestCommand;

/// <summary>
/// Initializes a new instance of the MainViewModel class.
Expand All @@ -25,6 +26,7 @@ public MainViewModel()

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}"); });
}

public SampleData Data
Expand All @@ -48,5 +50,16 @@ public ICommand OpenIssueCommand
OnPropertyChanged();
}
}

public ICommand OpenPullRequestCommand
{
get { return _openIssueCommand; }
set
{
if (Equals(value, _openPullRequestCommand)) return;
_openPullRequestCommand = value;
OnPropertyChanged();
}
}
}
}
56 changes: 56 additions & 0 deletions src/Showcase.WPF.DragDrop.NET45/Views/Issues.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
d:DesignHeight="400" d:DesignWidth="600">
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type ItemsControl}" BasedOn="{StaticResource DefaultItemsControl}" />
<Style TargetType="{x:Type ListBox}" BasedOn="{StaticResource DefaultListBoxStyle}" />
<Style TargetType="{x:Type ListView}" BasedOn="{StaticResource DefaultListViewStyle}" />
<Style TargetType="{x:Type TreeView}" BasedOn="{StaticResource DefaultTreeViewStyle}" />
Expand Down Expand Up @@ -342,6 +343,61 @@
</DockPanel>
</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}" />
<Button CommandParameter="73" ToolTip="Open #73 on Github" Style="{StaticResource GitHubPullRequestButtonStyle}" />
</Grid>
<ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource DefaultTextBlockStyle}"
Text="Empty ItemsControl with custom template on left side and a ListBox on the right side." />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ItemsControl Grid.Column="0"
x:Name="LeftItemsControlIssue73"
ItemsSource="{Binding Data.Collection3}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="2" Background="Transparent">
<iconPacks:PackIconMaterial Kind="Cart" VerticalAlignment="Center" />
<Label Content="{Binding}" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ListBox Grid.Column="1"
ItemsSource="{Binding Data.Collection1}"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True" />
</Grid>

<TextBlock Style="{StaticResource DefaultTextBlockStyle}"
Text="Customization (for left ItemsControl)" />
<CheckBox Margin="10 5" Content="IsDragSource"
IsChecked="{Binding ElementName=LeftItemsControlIssue73, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5" Content="IsDropTarget"
IsChecked="{Binding ElementName=LeftItemsControlIssue73, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5" Content="UseDefaultDragAdorner"
IsChecked="{Binding ElementName=LeftItemsControlIssue73, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Margin="10 5" Content="UseDefaultEffectDataTemplate"
IsChecked="{Binding ElementName=LeftItemsControlIssue73, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</ScrollViewer>
</DockPanel>
</TabItem>

</TabControl>

</Grid>
Expand Down

0 comments on commit d3580e1

Please sign in to comment.