Reputation: 11571
In My Application I Have ItemsControl with Canvas as ItemsPanelTemplate. Items of itemspanel source is thumb object and can drag and drage. if items drop out of screen view , I dont can scroll to view them. How I Want To Do? My Code Is Below :
<ItemsControl ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.Left" Value="{Binding XPosition}"/>
<Setter Property="Canvas.Top" Value="{Binding YPosition}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Upvotes: 1
Views: 1867
Reputation: 22739
First of all, you need to surround the ItemsControl
with a ScrollViewer
(unlike ListBox, which has it in its control template):
<ScrollViewer>
<ItemsControl> ... </ItemsControl>
<ScrollViewer>
Secondly, a Canvas
does not resize itself after its children. So you have a few options:
Margin
property.Width
and Height
properties.Upvotes: 2