Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight
 MeasureOverride Method
Other versions are also available for the following:
.NET Framework Class Library for Silverlight
FrameworkElement..::.MeasureOverride Method
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Provides the behavior for the "measure" pass of Silverlight layout. Classes can override this method to define their own measure pass behavior.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Visual Basic (Declaration)
Protected Overridable Function MeasureOverride ( _
    availableSize As Size _
) As Size
Visual Basic (Usage)
Dim availableSize As Size
Dim returnValue As Size

returnValue = Me.MeasureOverride(availableSize)
C#
protected virtual Size MeasureOverride(
    Size availableSize
)
Visual C++
protected:
virtual Size MeasureOverride(
    Size availableSize
)
JScript
protected function MeasureOverride(
    availableSize : Size
) : Size

Parameters

availableSize
Type: System.Windows..::.Size

The available size that this object can give to child objects. Infinity can be specified as a value to indicate that the object will size to whatever content is available.

Return Value

Type: System.Windows..::.Size

The size that this object determines it needs during layout, based on its calculations of child object allotted sizes.

This method has a default implementation that performs built-in layout for most Silverlight FrameworkElement classes.

Override MeasureOverride to implement custom layout sizing behavior for your class as it participates in the Silverlight layout system. Your implementation should do the following:

  • Iterate your class's particular collection of child objects that are part of layout, call Measure on each child object.

  • Immediately get DesiredSize on each child (this is set as a property after Measure is called).

  • Compute the net desired size of the parent based upon the running measurement of the size needed for child objects.

The return value of MeasureOverride should be the object's own desired size, which then becomes the measure input for the parent of the current object. This same process continues through the layout system until the root of the page/object tree is reached.

During this process, child objects might return a larger DesiredSize size than the initial availableSize to indicate that the child object wants more space. This might be handled in your own implementation by introducing a scrollable region, by resizing the parent control, by establishing some manner of stacked order, or any number of solutions for measuring or arranging content.

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker