|
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
|
번역
원본
|
FrameworkElement.MeasureOverride 메서드
네임스페이스: System.Windows
어셈블리: PresentationFramework(PresentationFramework.dll)
매개 변수
- availableSize
- 형식: System.Windows.Size
이 요소에서 자식 요소에 할당할 수 있는 크기입니다. 무한대 요소 콘텐츠에 사용할 수를 크기 수 있음을 나타내려면 값으로 지정할 수 있습니다.
레이아웃, 호출에 속하는 자식 개체의 특정 컬렉션 요소가 반복 Measure 각 자식 요소입니다. 즉시 얻을 DesiredSize 자식 (이 후 속성으로 설정 된 Measure 라고). Net 원하는 크기를 부모 자식 요소의 측정 시를 기준으로 계산 해야 합니다.
중요 |
|---|
protected override Size MeasureOverride(Size availableSize) { Size desiredSize = new Size(); foreach (UIElement child in VisualChildren) { child.Measure(availableSize); // do something with child.DesiredSize, either sum them directly or apply whatever logic your element has for reinterpreting the child sizes // if greater than availableSize, must decide what to do and which size to return } // desiredSize = ... computed sum of children's DesiredSize ...; // IMPORTANT: do not allow PositiveInfinity to be returned, that will raise an exception in the caller! // PositiveInfinity might be an availableSize input; this means that the parent does not care about sizing return desiredSize; }
public class PlotPanel : Panel { // Default public constructor public PlotPanel() : base() { } // Override the default Measure method of Panel protected override Size MeasureOverride(Size availableSize) { Size panelDesiredSize = new Size(); // In our example, we just have one child. // Report that our panel requires just the size of its only child. foreach (UIElement child in InternalChildren) { child.Measure(availableSize); panelDesiredSize = child.DesiredSize; } return panelDesiredSize ; } protected override Size ArrangeOverride(Size finalSize) { foreach (UIElement child in InternalChildren) { double x = 50; double y = 50; child.Arrange(new Rect(new Point(x, y), child.DesiredSize)); } return finalSize; // Returns the final Arranged size } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)
.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
중요