2011-03-05 74 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.)

所有的 “子项目”,这是直接的内容的画布。 在你的情况下,你现在必须根据实际的滚动状态来移动它们。

所以,如果孩子不存在,你不会延长画布...

相关问题