Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Método UIElement.Measure (Size)

 

Atualiza DesiredSize de um UIElement. Elementos pai chamam esse método de suas próprias implementações MeasureCore para formar uma atualização de layout recursiva. Chamar esse método constitui a primeira passagem (a passagem "Medida") de uma atualização de layout.

Namespace:   System.Windows
Assembly:  PresentationCore (em PresentationCore.dll)

public void Measure(
	Size availableSize
)

Parâmetros

availableSize
Type: System.Windows.Size

O espaço disponível que um elemento pai pode alocar um elemento filho. Um elemento filho pode solicitar um espaço maior do que o disponível. O tamanho fornecido pode ser acomodado se a rolagem for possível no modelo de conteúdo do elemento atual.

Computation of layout positioning in TLA#tla_winclient is comprised of a M:System.Windows.UIElement.Measure(System.Windows.Size) call and an M:System.Windows.UIElement.Arrange(System.Windows.Rect) call. During the M:System.Windows.UIElement.Measure(System.Windows.Size) call, an element determines its size requirements by using an availableSize input. During the M:System.Windows.UIElement.Arrange(System.Windows.Rect) call, the element size is finalized.

availableSize can be any number from zero to infinite. Elements participating in layout should return the minimum Size they require for a given availableSize.

When a layout is first instantiated, it always receives a M:System.Windows.UIElement.Measure(System.Windows.Size) call before M:System.Windows.UIElement.Arrange(System.Windows.Rect). However, after the first layout pass, it may receive an M:System.Windows.UIElement.Arrange(System.Windows.Rect) call without a M:System.Windows.UIElement.Measure(System.Windows.Size); this can happen when a property that affects only M:System.Windows.UIElement.Arrange(System.Windows.Rect) is changed (such as alignment), or when the parent receives an M:System.Windows.UIElement.Arrange(System.Windows.Rect) without a M:System.Windows.UIElement.Measure(System.Windows.Size). A M:System.Windows.UIElement.Measure(System.Windows.Size) call will automatically invalidate an M:System.Windows.UIElement.Arrange(System.Windows.Rect) call.

Layout updates happen asynchronously, such that the main thread is not waiting for every possible layout change. Querying an element via code-behind checking of property values may not immediately reflect changes to properties that interact with the sizing or layout characteristics (the P:System.Windows.FrameworkElement.Width property, for example).

System_CAPS_noteObservação

Layout updates can be forced by using the M:System.Windows.UIElement.UpdateLayout method. However, calling this method is usually unnecessary and can cause poor performance.

The layout system keeps two separate queues of invalid layouts, one for M:System.Windows.UIElement.Measure(System.Windows.Size) and one for M:System.Windows.UIElement.Arrange(System.Windows.Rect). The layout queue is sorted based upon the order of elements in the visual tree of the element performing layout; elements higher in the tree are at the top of the queue, to avoid redundant layouts caused by repeated changes in parents. Duplicate entries are automatically removed from the queue, and elements are automatically removed from the queue if they are already layout-validated.

When updating layout, the M:System.Windows.UIElement.Measure(System.Windows.Size) queue is emptied first, followed by the M:System.Windows.UIElement.Arrange(System.Windows.Rect) queue. An element in the M:System.Windows.UIElement.Arrange(System.Windows.Rect) queue will never be arranged if there is an element in the M:System.Windows.UIElement.Measure(System.Windows.Size) queue.

.NET Framework
Disponível desde 3.0
Silverlight
Disponível desde 2.0
Windows Phone Silverlight
Disponível desde 7.0
Retornar ao início
Mostrar: