Forked from punker76/ItemsControlWithScrollViewer.xaml
Created
January 3, 2024 01:56
-
-
Save myd7349/5ed0757479f2fdd24e913e32c3f5d84a to your computer and use it in GitHub Desktop.
ItemsControl with ScrollViewer inside Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:dd="urn:gong-wpf-dragdrop"> | |
<Grid> | |
<ItemsControl x:Name="pnlBilder" | |
HorizontalAlignment="Center" | |
Width="300" Height="100" | |
dd:DragDrop.IsDragSource="True" | |
ScrollViewer.HorizontalScrollBarVisibility="Disabled" | |
ScrollViewer.VerticalScrollBarVisibility="Auto" | |
dd:DragDrop.IsDropTarget="True" | |
dd:DragDrop.DropScrollingMode="Both" > | |
<ItemsControl.ItemTemplate> | |
<DataTemplate> | |
<local:CoolView x:Name="ctrlView" Width="100" Height="100" /> | |
</DataTemplate> | |
</ItemsControl.ItemTemplate> | |
<ItemsControl.ItemsPanel> | |
<ItemsPanelTemplate> | |
<WrapPanel /> | |
</ItemsPanelTemplate> | |
</ItemsControl.ItemsPanel> | |
<ItemsControl.Template> | |
<ControlTemplate TargetType="{x:Type ItemsControl}"> | |
<Border x:Name="Border" | |
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" | |
Background="{TemplateBinding Background}" | |
BorderBrush="{TemplateBinding BorderBrush}" | |
BorderThickness="{TemplateBinding BorderThickness}"> | |
<ScrollViewer Margin="0" | |
Focusable="False" | |
Padding="{TemplateBinding Padding}" | |
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" | |
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" | |
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" | |
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"> | |
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |
</ScrollViewer> | |
</Border> | |
<ControlTemplate.Triggers> | |
<Trigger Property="IsEnabled" Value="False"> | |
<Setter TargetName="Border" Property="Background" Value="Gray" /> | |
<Setter TargetName="Border" Property="BorderBrush" Value="Silver" /> | |
</Trigger> | |
</ControlTemplate.Triggers> | |
</ControlTemplate> | |
</ItemsControl.Template> | |
</ItemsControl> | |
</Grid> | |
</Page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment