Skip to content

Commit b07331a

Browse files
committed
refactor: use settings view on more samples
1 parent cf44b5f commit b07331a

9 files changed

+390
-307
lines changed

src/Showcase/App.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
<Style x:Key="DefaultTabItemStyle" TargetType="{x:Type TabItem}" />
8383
<Style x:Key="DefaultTabControlStyle" TargetType="{x:Type TabControl}">
84-
<Setter Property="Height" Value="100" />
84+
<Setter Property="Height" Value="150" />
8585
<Setter Property="ItemContainerStyle" Value="{StaticResource DefaultTabItemStyle}" />
8686
<Setter Property="Margin" Value="4" />
8787
<Setter Property="TabStripPlacement" Value="Top" />

src/Showcase/Views/DataGridSamples.xaml

+19-15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
xmlns:dd="urn:gong-wpf-dragdrop"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
77
xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
8+
xmlns:views="clr-namespace:Showcase.WPF.DragDrop.Views"
89
d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
910
d:DesignHeight="300"
1011
d:DesignWidth="300"
@@ -26,7 +27,13 @@
2627
<ColumnDefinition Width="*" />
2728
<ColumnDefinition Width="*" />
2829
</Grid.ColumnDefinitions>
30+
<Grid.RowDefinitions>
31+
<RowDefinition Height="*" />
32+
<RowDefinition Height="Auto" />
33+
</Grid.RowDefinitions>
34+
2935
<DataGrid x:Name="LeftBoundDataGrid"
36+
Grid.Row="0"
3037
Grid.Column="0"
3138
dd:DragDrop.DropScrollingMode="VerticalOnly"
3239
dd:DragDrop.IsDragSource="True"
@@ -37,27 +44,24 @@
3744
CanUserDeleteRows="False"
3845
IsReadOnly="True"
3946
ItemsSource="{Binding Data.DataGridCollection1}" />
40-
<DataGrid Grid.Column="1"
47+
<DataGrid x:Name="RightBoundDataGrid"
48+
Grid.Row="0"
49+
Grid.Column="1"
4150
dd:DragDrop.IsDragSource="True"
4251
dd:DragDrop.IsDropTarget="True"
4352
CanUserAddRows="True"
4453
CanUserDeleteRows="True"
4554
ItemsSource="{Binding Data.DataGridCollection2}" />
46-
</Grid>
4755

48-
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left DataGrid)" />
49-
<CheckBox Margin="10 5"
50-
Content="IsDragSource"
51-
IsChecked="{Binding ElementName=LeftBoundDataGrid, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
52-
<CheckBox Margin="10 5"
53-
Content="IsDropTarget"
54-
IsChecked="{Binding ElementName=LeftBoundDataGrid, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
55-
<CheckBox Margin="10 5"
56-
Content="UseDefaultDragAdorner"
57-
IsChecked="{Binding ElementName=LeftBoundDataGrid, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
58-
<CheckBox Margin="10 5"
59-
Content="UseDefaultEffectDataTemplate"
60-
IsChecked="{Binding ElementName=LeftBoundDataGrid, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
56+
<views:SettingsView Grid.Row="1"
57+
Grid.Column="0"
58+
Caption="Customization (for left DataGrid)"
59+
DataContext="{x:Reference LeftBoundDataGrid}" />
60+
<views:SettingsView Grid.Row="1"
61+
Grid.Column="1"
62+
Caption="Customization (for right DataGrid)"
63+
DataContext="{x:Reference RightBoundDataGrid}" />
64+
</Grid>
6165
</StackPanel>
6266
</ScrollViewer>
6367
</DockPanel>

src/Showcase/Views/ListBoxSamples.xaml

+60-72
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@
8080
<ColumnDefinition Width="*" />
8181
<ColumnDefinition Width="*" />
8282
</Grid.ColumnDefinitions>
83+
<Grid.RowDefinitions>
84+
<RowDefinition Height="*" />
85+
<RowDefinition Height="Auto" />
86+
</Grid.RowDefinitions>
87+
8388
<ListBox x:Name="LeftUnboundListBox"
89+
Grid.Row="0"
8490
Grid.Column="0"
8591
dd:DragDrop.IsDragSource="True"
8692
dd:DragDrop.IsDropTarget="True"
@@ -91,7 +97,9 @@
9197
<ListBoxItem>Unbound Item4</ListBoxItem>
9298
<ListBoxItem>Unbound Item5</ListBoxItem>
9399
</ListBox>
94-
<ListBox Grid.Column="1"
100+
<ListBox x:Name="RightUnboundListBox"
101+
Grid.Row="0"
102+
Grid.Column="1"
95103
dd:DragDrop.IsDragSource="True"
96104
dd:DragDrop.IsDropTarget="True">
97105
<ListBoxItem>Unbound Item6</ListBoxItem>
@@ -100,21 +108,16 @@
100108
<ListBoxItem>Unbound Item9</ListBoxItem>
101109
<ListBoxItem>Unbound Item10</ListBoxItem>
102110
</ListBox>
103-
</Grid>
104111

105-
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
106-
<CheckBox Margin="10 5"
107-
Content="IsDragSource"
108-
IsChecked="{Binding ElementName=LeftUnboundListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
109-
<CheckBox Margin="10 5"
110-
Content="IsDropTarget"
111-
IsChecked="{Binding ElementName=LeftUnboundListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
112-
<CheckBox Margin="10 5"
113-
Content="UseDefaultDragAdorner"
114-
IsChecked="{Binding ElementName=LeftUnboundListBox, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
115-
<CheckBox Margin="10 5"
116-
Content="UseDefaultEffectDataTemplate"
117-
IsChecked="{Binding ElementName=LeftUnboundListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
112+
<views:SettingsView Grid.Row="1"
113+
Grid.Column="0"
114+
Caption="Customization (for left ListBox)"
115+
DataContext="{x:Reference LeftUnboundListBox}" />
116+
<views:SettingsView Grid.Row="1"
117+
Grid.Column="1"
118+
Caption="Customization (for right ListBox)"
119+
DataContext="{x:Reference RightUnboundListBox}" />
120+
</Grid>
118121
</StackPanel>
119122
</ScrollViewer>
120123
</DockPanel>
@@ -294,47 +297,35 @@
294297
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
295298
<StackPanel>
296299
<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." />
297-
<ListBox x:Name="GroupedListBox"
298-
dd:DragDrop.DragDirectlySelectedOnly="True"
299-
dd:DragDrop.DropHandler="{Binding Data.GroupedDropHandler}"
300-
dd:DragDrop.IsDragSource="True"
301-
dd:DragDrop.IsDropTarget="True"
302-
DisplayMemberPath="Caption"
303-
ItemsSource="{Binding Source={StaticResource GroupedCollectionViewSource}}"
304-
SelectionMode="Extended">
305-
<ListBox.GroupStyle>
306-
<x:Static Member="GroupStyle.Default" />
307-
</ListBox.GroupStyle>
308-
</ListBox>
300+
<Grid>
301+
<Grid.RowDefinitions>
302+
<RowDefinition Height="*" />
303+
<RowDefinition Height="Auto" />
304+
</Grid.RowDefinitions>
305+
<ListBox x:Name="GroupedListBox"
306+
Grid.Row="0"
307+
dd:DragDrop.DragDirectlySelectedOnly="True"
308+
dd:DragDrop.DropHandler="{Binding Data.GroupedDropHandler}"
309+
dd:DragDrop.IsDragSource="True"
310+
dd:DragDrop.IsDropTarget="True"
311+
DisplayMemberPath="Caption"
312+
ItemsSource="{Binding Source={StaticResource GroupedCollectionViewSource}}"
313+
SelectionMode="Extended">
314+
<ListBox.GroupStyle>
315+
<x:Static Member="GroupStyle.Default" />
316+
</ListBox.GroupStyle>
317+
</ListBox>
309318

310-
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization" />
311-
<CheckBox Margin="10 5"
312-
Content="IsDragSource"
313-
IsChecked="{Binding ElementName=GroupedListBox, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
314-
<CheckBox Margin="10 5"
315-
Content="IsDropTarget"
316-
IsChecked="{Binding ElementName=GroupedListBox, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
317-
<CheckBox Margin="10 5"
318-
Content="UseDefaultDragAdorner"
319-
IsChecked="{Binding ElementName=GroupedListBox, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
320-
<CheckBox Margin="10 5"
321-
Content="UseDefaultEffectDataTemplate"
322-
IsChecked="{Binding ElementName=GroupedListBox, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
319+
<views:SettingsView Grid.Row="1"
320+
Caption="Customization"
321+
DataContext="{x:Reference GroupedListBox}" />
322+
</Grid>
323323
</StackPanel>
324324
</ScrollViewer>
325325
</DockPanel>
326326
</TabItem>
327327

328328
<TabItem Header="DragDropKeyStates">
329-
<TabItem.Resources>
330-
<ObjectDataProvider x:Key="DragDropKeyStatesEnumValues"
331-
MethodName="GetValues"
332-
ObjectType="{x:Type DragDropKeyStates}">
333-
<ObjectDataProvider.MethodParameters>
334-
<x:Type TypeName="DragDropKeyStates" />
335-
</ObjectDataProvider.MethodParameters>
336-
</ObjectDataProvider>
337-
</TabItem.Resources>
338329
<DockPanel LastChildFill="True">
339330
<TextBlock DockPanel.Dock="Top"
340331
Style="{StaticResource SampleHeaderTextBlockStyle}"
@@ -347,40 +338,37 @@
347338
<ColumnDefinition Width="*" />
348339
<ColumnDefinition Width="*" />
349340
</Grid.ColumnDefinitions>
341+
<Grid.RowDefinitions>
342+
<RowDefinition Height="*" />
343+
<RowDefinition Height="Auto" />
344+
</Grid.RowDefinitions>
345+
350346
<ListBox x:Name="LeftListBoxOfDragDropKeyStatesSample"
347+
Grid.Row="0"
351348
Grid.Column="0"
352349
dd:DragDrop.DragDropCopyKeyState="ControlKey"
353350
dd:DragDrop.IsDragSource="True"
354351
dd:DragDrop.IsDropTarget="True"
355352
dd:DragDrop.UseDefaultEffectDataTemplate="True"
356353
ItemsSource="{Binding Data.Collection1}" />
357-
<ListBox Grid.Column="1"
354+
<ListBox x:Name="RightListBoxOfDragDropKeyStatesSample"
355+
Grid.Row="0"
356+
Grid.Column="1"
358357
dd:DragDrop.IsDragSource="True"
359358
dd:DragDrop.IsDropTarget="True"
360359
ItemsSource="{Binding Data.Collection2}" />
361-
</Grid>
362360

363-
<TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left ListBox)" />
364-
<StackPanel Margin="10 5" Orientation="Horizontal">
365-
<TextBlock VerticalAlignment="Center" Text="DragDropCopyKeyState" />
366-
<ComboBox Width="200"
367-
Margin="5 0 0 0"
368-
VerticalAlignment="Center"
369-
ItemsSource="{Binding Source={StaticResource DragDropKeyStatesEnumValues}}"
370-
SelectedItem="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.DragDropCopyKeyState), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
371-
</StackPanel>
372-
<CheckBox Margin="10 5"
373-
Content="IsDragSource"
374-
IsChecked="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
375-
<CheckBox Margin="10 5"
376-
Content="IsDropTarget"
377-
IsChecked="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
378-
<CheckBox Margin="10 5"
379-
Content="UseDefaultDragAdorner"
380-
IsChecked="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
381-
<CheckBox Margin="10 5"
382-
Content="UseDefaultEffectDataTemplate"
383-
IsChecked="{Binding ElementName=LeftListBoxOfDragDropKeyStatesSample, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
361+
<views:SettingsView Grid.Row="1"
362+
Grid.Column="0"
363+
Caption="Customization (for left ListBox)"
364+
DataContext="{x:Reference LeftListBoxOfDragDropKeyStatesSample}"
365+
ShowCopyKeyState="True" />
366+
<views:SettingsView Grid.Row="1"
367+
Grid.Column="1"
368+
Caption="Customization (for right ListBox)"
369+
DataContext="{x:Reference RightListBoxOfDragDropKeyStatesSample}"
370+
ShowCopyKeyState="True" />
371+
</Grid>
384372
</StackPanel>
385373
</ScrollViewer>
386374
</DockPanel>

0 commit comments

Comments
 (0)