2017-09-26 82 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> 

我希望这有助于!