title: Click, Drag, and Scroll Canvas View
body: <p>I have a ListBox with a ItemsPanelTemplate of Canvas. I know the ScrollViewer will not work with the Canvas unless its given a height and width. I DO NOT want to give the canvas a height and width because it will not always be constant. Is there any other work around or tricks anyone has gotten to work for this situation. I know I can't be the only one with this problem. Thanks in advance here is my code so far.</p>
  
  <p>Another problem is I am unable to place the ScrollViewer inside the ItemsPanelTemplate because it can only have one element nested inside.</p>
  
  <p><strong>This also restricts me from placing the canvas inside a grid to get positioning.</strong></p>
  
  <p>XAML:</p>
  
  <pre><code>    &lt;!--Core Viewer--&gt;
      &lt;ScrollViewer x:Name="scrollViewer"
                    VerticalScrollBarVisibility="Hidden"
                    HorizontalScrollBarVisibility="Hidden"&gt;
  
          &lt;ListBox x:Name="objCoreViewer"
               ItemsSource="{Binding ItemsSource}"
               Background="LightGray"
               SelectionChanged="objCoreViewer_SelectionChanged"
               ItemTemplateSelector="{DynamicResource CoreViewerDataTemplateSelector}"
               ItemContainerStyleSelector="{DynamicResource ItemContainerStyleSelector}"
               PreviewMouseWheel="objCoreViewer_PreviewMouseWheel"&gt;
  
              &lt;!-- Core Map Canvas --&gt;
  
              &lt;ListBox.ItemsPanel&gt;
  
                  &lt;ItemsPanelTemplate&gt;
                      &lt;Canvas x:Name="objCoreViewerCanvas"
                              Background="Transparent"&gt;
                          &lt;Canvas.LayoutTransform&gt;
                              &lt;ScaleTransform ScaleX="{Binding Path=Value, ElementName=ZoomSlider}"
                                              ScaleY="{Binding Path=Value, ElementName=ZoomSlider}" /&gt;
                          &lt;/Canvas.LayoutTransform&gt;
                      &lt;/Canvas&gt;
                  &lt;/ItemsPanelTemplate&gt;
  
              &lt;/ListBox.ItemsPanel&gt;
  
          &lt;/ListBox&gt;
  
      &lt;/ScrollViewer&gt;
  </code></pre>