Skip to content

Commit

Permalink
add example for #119
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Jan 17, 2015
1 parent 51933a6 commit 669e50c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Examples/DefaultsExample/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public Data()
this.Collection1 = new ObservableCollection<string>();
this.Collection2 = new ObservableCollection<string>();
this.Collection3 = new ObservableCollection<string>();
this.Collection4 = new ObservableCollection<string>();
this.CustomCollection1 = new ObservableCollection<CustomDataModel>();
this.CustomCollection2 = new ObservableCollection<CustomDataModel>();

Expand All @@ -75,6 +76,10 @@ public Data()
this.CustomCollection1.Add(new CustomDataModel { Name = "Custom Item " + n });
}

for (var n = 0; n < 4; ++n) {
this.Collection4.Add("Content " + n);
}

this.GroupedCollection = new ObservableCollection<GroupedItem>();
for (var g = 0; g < 4; ++g) {
for (var i = 0; i < 2; ++i) {
Expand All @@ -100,6 +105,7 @@ public Data()
public ObservableCollection<string> Collection1 { get; private set; }
public ObservableCollection<string> Collection2 { get; private set; }
public ObservableCollection<string> Collection3 { get; private set; }
public ObservableCollection<string> Collection4 { get; private set; }
public ObservableCollection<CustomDataModel> CustomCollection1 { get; private set; }
public ObservableCollection<CustomDataModel> CustomCollection2 { get; private set; }
public ObservableCollection<GroupedItem> GroupedCollection { get; private set; }
Expand Down
66 changes: 62 additions & 4 deletions Examples/DefaultsExample/Window(NET4).xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
Height="500"
Width="800">

<Window.DataContext>
<local:Data />
</Window.DataContext>

<Window.Resources>
<DataTemplate x:Key="DragAdorner">
<Border Background="Silver"
Expand Down Expand Up @@ -34,10 +38,6 @@
</CollectionViewSource>
</Window.Resources>

<Window.DataContext>
<local:Data />
</Window.DataContext>

<TabControl TabStripPlacement="Left">
<TabItem Header="Issue 42">
<Grid>
Expand Down Expand Up @@ -1039,5 +1039,63 @@
dd:DragDrop.IsDropTarget="True" />
</Grid>
</TabItem>

<TabItem Header="ItemsControl with ItemsControl and Buttons">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock Grid.Row="0"
Margin="0,8,0,8"
TextWrapping="Wrap">
Demonstrates the behaviour with an ItemsControl that has a DataTemplate with an ItemsControl and Buttons inside.
</TextBlock>

<ScrollViewer Grid.Row="1"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding Collection1}"
dd:DragDrop.DragDropContext="OuterContext"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultEffectDataTemplate="True"
dd:DragDrop.DragAdornerTemplate="{StaticResource DragAdorner}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Background="Coral"
Margin="0,1,0,1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="2"
FontSize="16"
Text="{Binding}" />
<ItemsControl Grid.Row="1"
dd:DragDrop.DragDropContext="InnerContext"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Collection4}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Background="#FDA07E">
<Button Content="{Binding}"
HorizontalAlignment="Left"
Margin="20,1,1,1"
Click="ButtonBase_OnClick" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</TabItem>
</TabControl>
</Window>
5 changes: 5 additions & 0 deletions Examples/DefaultsExample/Window(NET4).xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@ private void FilterCheckBox_Clicked(object sender, RoutedEventArgs e)
return (number & 0x01) == 0;
};
}

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
MessageBox.Show(this, "Got the click.");
}
}
}
6 changes: 6 additions & 0 deletions GongSolutions.Wpf.DragDrop (NET4).sln.GhostDoc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<GhostDoc>
<IgnoreFilePatterns>
<IgnoreFilePattern>*.min.js</IgnoreFilePattern>
<IgnoreFilePattern>jquery*.js</IgnoreFilePattern>
</IgnoreFilePatterns>
</GhostDoc>

0 comments on commit 669e50c

Please sign in to comment.