2011-03-05 87 views
0

我正在使用WPF創建應用程序。其中我實現了IScrollInfo界面來獲取畫布的可見區域。我重寫方法MeasureOverride(Size availableSize)獲取視野,但我得到的是我無法理解的錯誤:錯誤:錯誤名稱'Children'在當前上下文中不存在

protected override Size MeasureOverride(Size availableSize) 
     { 

      foreach (UIElement child in Children) 
      { 

       child.Measure(availableSize); 
       resultSize.Width = Math.Max(resultSize.Width, 
       child.DesiredSize.Width); 
       resultSize.Height = Math.Max(resultSize.Height, 
         child.DesiredSize.Height); 
         extent.Width += child.DesiredSize.Width; 
      } 

      resultSize.Width = double.IsPositiveInfinity(availableSize.Width)? resultSize.Width : availableSize.Width; 
      resultSize.Height = double.IsPositiveInfinity(availableSize.Height)? resultSize.Height : availableSize.Height; 
      extent.Height = resultSize.Height; 

      if ((_viewport != resultSize || _extent != extent) && ScrollOwner != null) 

      { 
         _viewport = resultSize; 
         _extent = extent; 

         ScrollOwner.InvalidateScrollInfo(); 
      } 

      return resultSize; 
     } 

什麼是它的孩子..

回答

0

當你使用一個Canvas,兒童會是:

從MSDN Canvas

Children Gets a UIElementCollection of child elements of this Panel. (Inherited from Panel.)

所有的 「子項目」,這是直接的內容的畫布。 在你的情況下,你現在必須根據實際的滾動狀態來移動它們。

所以,如果孩子不存在,你不會延長畫布...

相關問題