Positions child objects and determines a size for a UIElement. Parent objects that implement custom layout for their child elements should call this method from their layout override implementations to form a recursive layout update.
Assembly: System.Windows (in System.Windows.dll)
There is no reason to call Measure or outside of the context of overriding methods that perform custom layout actions. Silverlight layout works autonomously, based on detecting changes to the object tree and layout-relevant properties at run time. For more information, see Silverlight Layout System.
Typically, calls to will incorporate a finalRect that uses the height and width values from DesiredSize for each element . Exceptions to this typical behavior might be necessary if an element holds a DesiredSize that the layout parent cannot accommodate, or if the sum total of all child element DesiredSize values cannot be accommodated or arranged. In such cases the child element content might be clipped, resized, or placed in a scroll region, which all depends on the specific functionality that is enabled in the layout parent container.
The following example shows how you would use within an ArrangeOverride implementation.
'Second arrange all children and return final size of panel Protected Overloads Overrides Function ArrangeOverride(ByVal finalSize As Size) As Size 'Get the collection of children Dim mychildren As UIElementCollection = Children 'Get total number of children Dim count As Integer = mychildren.Count 'Arrange children 'We're only allowing 9 children in this panel. More children will get a 0x0 layout slot. Dim i As Integer For i = 0 To 8 'Get (left, top) origin point for the element in the 3x3 block Dim cellOrigin As Point = GetOrigin(i, 3, New Size(100, 100)) 'Arrange child 'Get desired height and width. This will not be larger than 100x100 as set in MeasureOverride. Dim dw As Double = mychildren(i).DesiredSize.Width Dim dh As Double = mychildren(i).DesiredSize.Height mychildren(i).Arrange(New Rect(cellOrigin.X, cellOrigin.Y, dw, dh)) Next For i = 9 To count - 1 'Give the remaining children a 0x0 layout slot mychildren(i).Arrange(New Rect(0, 0, 0, 0)) Next 'Return final size of the panel Return New Size(300, 300) End Function 'Calculate point origin of the Block you are in Protected Function GetOrigin(ByVal blockNum As Integer, ByVal blocksPerRow As Integer, ByVal itemSize As Size) As Point 'Get row number (zero-based) Dim row As Integer = CInt(Math.Floor(blockNum / blocksPerRow)) 'Get column number (zero-based) Dim column As Integer = blockNum - blocksPerRow * row 'Calculate origin Dim origin As New Point(itemSize.Width * column, itemSize.Height * row) Return origin End Function
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.