이 문서는 기계 번역을 이용하여 번역되었습니다. 문서를 영문으로 보려면 영문 확인란을 선택하세요. 마우스 포인터를 텍스트 위로 이동시켜 팝업 창에서 영문 텍스트를 표시할 수도 있습니다.
번역
영문

UIElement.DesiredSize 속성

 

게시 날짜: 2016년 11월

레이아웃 프로세스의 측정 단계 중 이 요소가 계산한 크기를 가져옵니다.

네임스페이스:   System.Windows
어셈블리:  PresentationCore(PresentationCore.dll에 있음)

public Size DesiredSize { get; }

속성 값

Type: System.Windows.Size

정렬 단계에 필요한 크기인 계산된 크기입니다.

The value returned by this property will only be a valid measurement if the value of the P:System.Windows.UIElement.IsMeasureValid property is true.

DesiredSize is typically checked as one of the measurement factors when you implement layout behavior overrides such as ArrangeOverride, MeasureOverride, or OnRender (in the OnRender case, you might check RenderSize instead, but this depends on your implementation). Depending on the scenario, DesiredSize might be fully respected by your implementation logic, constraints on DesiredSize might be applied, and such constraints might also change other characteristics of either the parent element or child element. For example, a control that supports scrollable regions (but chooses not to derive from the WPF framework-level controls that already enable scrollable regions) could compare available size to DesiredSize. The control could then set an internal state that enabled scrollbars in the UI for that control. Or, DesiredSize could potentially also be ignored in certain scenarios.

The following example shows P:System.Windows.UIElement.DesiredSize as part of a M:System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size) implementation. Notice how M:System.Windows.UIElement.Measure(System.Windows.Size) is called immediately prior to obtaining P:System.Windows.UIElement.DesiredSize. This assures that P:System.Windows.UIElement.DesiredSize holds a legitimate value.

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 ;
}

.NET Framework
3.0 이후 사용 가능
Silverlight
2.0 이후 사용 가능
Windows Phone Silverlight
7.0 이후 사용 가능
맨 위로 이동
표시: