2017-09-26 54 views
0

我在ItemsControl中使用Canvas,其中可以繪製矩形,圓等形狀。我想調整大小並移動繪製的形狀。我嘗試使用裝飾,但沒有找到一種方法來在ItemsControl中使用裝飾,這可能嗎?ItemsControl內的裝飾器

   <ItemsControl.ItemsPanel> 
        <ItemsPanelTemplate> 
         <zc:ZoomableCanvas Loaded="Canvas_Loaded" 
            RealizationLimit="1000" 
            RealizationRate="10" 
            RealizationPriority="Background" 
            ApplyTransform="False" 
            Scale="{Binding ZoomableCanvas.Scale}" 
            Offset="{Binding ZoomableCanvas.Offset}" ClipToBounds="True" 
            Width="{Binding ZoomableCanvas.ActualWidth}" 
            Height="{Binding ZoomableCanvas.ActualHeight}" 
            > 
         </zc:ZoomableCanvas> 
        </ItemsPanelTemplate> 
       </ItemsControl.ItemsPanel> 

回答

1

這可能是答案有點晚,但我寫它以供將來參考。

您正在使用的Canvas只能顯示裝飾者,如果它生活在AdornerDecorator之內。試試這個:

<AdornerDecorator> 
    <ItemsControl.ItemsPanel> 
     <ItemsPanelTemplate> 
      <zc:ZoomableCanvas Loaded="Canvas_Loaded" 
           RealizationLimit="1000" 
           RealizationRate="10" 
           RealizationPriority="Background" 
           ApplyTransform="False" 
           Scale="{Binding ZoomableCanvas.Scale}" 
           Offset="{Binding ZoomableCanvas.Offset}" 
           ClipToBounds="True" 
           Width="{Binding ZoomableCanvas.ActualWidth}" 
           Height="{Binding ZoomableCanvas.ActualHeight}" 
           > 
      </zc:ZoomableCanvas> 
     </ItemsPanelTemplate> 
    </ItemsControl.ItemsPanel> 
</AdornerDecorator> 

我希望這有助於!