Exportar (0) Imprimir
Expandir todo
Este artículo se tradujo de forma manual. Mueva el puntero sobre las frases del artículo para ver el texto original.
Traducción
Original

FrameworkElement.MinHeight (Propiedad)

Obtiene o establece la restricción de alto mínimo del elemento.

Espacio de nombres:  System.Windows
Ensamblado:  PresentationFramework (en PresentationFramework.dll)
XMLNS para XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

[TypeConverterAttribute(typeof(LengthConverter))]
[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)]
public double MinHeight { get; set; }
<object MinHeight="double"/>
- or -
<object MinHeight="qualifiedDouble"/>

Valores XAML

double

Double

Representación de cadena de un valor de tipo Double igual o mayor que 0,0. Esto se interpreta como medida de device-independent unit (1/96th inch). No es preciso incluir explícitamente separadores decimales en las cadenas. Por ejemplo, el valor 1 es aceptable.

Se aplican las mismas restricciones en los intervalos de Double que se mencionan en la sección Valor de propiedad.

qualifiedDouble

Valor double, descrito anteriormente, seguido de una de las siguientes cadenas de declaración de unidades: px, in, cm, pt.

px (valor predeterminado) es device-independent units (1/96th inch per unit)

in significa pulgadas; 1 pda.==96 px

cm significa centímetros; 1 cm==(96/2,54) px

pt significa puntos; 1 pt = (96/72) px

Valor de propiedad

Tipo: System.Double
Alto mínimo del elemento, en device-independent units (1/96th inch per unit). El valor predeterminado es 0,0. Este valor puede ser igual o mayor que 0,0. Sin embargo, PositiveInfinity y Double.NaN NO son valores válidos.

Campo de identificador

MinHeightProperty

Propiedades de metadatos establecidas en true.

AffectsMeasure

Ésta es una de las tres propiedades de FrameworkElement que especifican información de alto. Las otras dos son Height y MaxHeight. Si existe un conflicto entre estos valores, el orden de aplicación para determinar el alto real es: primero se debe aplicar la propiedad MinHeight, después la propiedad MaxHeight y, finalmente, si cada una de ellas está dentro de los límites, la propiedad Height.

Las restricciones del valor de Double se aplican mediante un mecanismo de ValidateValueCallback. Si intenta establecer un valor no válido, se produce una excepción en tiempo de ejecución.

This example visually shows the differences in rendering behavior among the four height-related properties in Windows Presentation Foundation (WPF).

The FrameworkElement class exposes four properties that describe the height characteristics of an element. These four properties can conflict, and when they do, the value that takes precedence is determined as follows: the MinHeight value takes precedence over the MaxHeight value, which in turn takes precedence over the Height value. A fourth property, ActualHeight, is read-only, and reports the actual height as determined by interactions with the layout process.

The following Extensible Application Markup Language (XAML) examples draw a Rectangle element (rect1) as a child of Canvas. You can change the height properties of a Rectangle by using a series of ListBox elements that represent the property values of MinHeight, MaxHeight, and Height. In this manner, the precedence of each property is visually displayed.


<Canvas Height="200" MinWidth="200" Background="#b0c4de" VerticalAlignment="Top"  HorizontalAlignment="Center" Name="myCanvas" Margin="0,0,0,50">
    <Rectangle HorizontalAlignment="Center" Canvas.Top="50" Canvas.Left="50"  Name="rect1" Fill="#4682b4" Height="100" Width="100"/>
</Canvas>


...


    <TextBlock Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle Height:</TextBlock>
    <ListBox Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" Height="50" Width="50" SelectionChanged="changeHeight">
      <ListBoxItem>25</ListBoxItem>
      <ListBoxItem>50</ListBoxItem>
      <ListBoxItem>75</ListBoxItem>
      <ListBoxItem>100</ListBoxItem>
      <ListBoxItem>125</ListBoxItem>
      <ListBoxItem>150</ListBoxItem>
      <ListBoxItem>175</ListBoxItem>
      <ListBoxItem>200</ListBoxItem>
    </ListBox>

	<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle MinHeight:</TextBlock>
    <ListBox Grid.Column="3" Grid.Row="1" Margin="10,0,0,0" Height="50" Width="50" SelectionChanged="changeMinHeight">
      <ListBoxItem>25</ListBoxItem>
      <ListBoxItem>50</ListBoxItem>
      <ListBoxItem>75</ListBoxItem>
      <ListBoxItem>100</ListBoxItem>
      <ListBoxItem>125</ListBoxItem>
      <ListBoxItem>150</ListBoxItem>
      <ListBoxItem>175</ListBoxItem>
      <ListBoxItem>200</ListBoxItem>
  </ListBox>      

    <TextBlock Grid.Row="1" Grid.Column="4" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle MaxHeight:</TextBlock>
    <ListBox Grid.Column="5" Grid.Row="1" Margin="10,0,0,0" Height="50" Width="50" SelectionChanged="changeMaxHeight">
      <ListBoxItem>25</ListBoxItem>
      <ListBoxItem>50</ListBoxItem>
      <ListBoxItem>75</ListBoxItem>
      <ListBoxItem>100</ListBoxItem>
      <ListBoxItem>125</ListBoxItem>
      <ListBoxItem>150</ListBoxItem>
      <ListBoxItem>175</ListBoxItem>
      <ListBoxItem>200</ListBoxItem> 
    </ListBox>


The following code-behind examples handle the events that the SelectionChanged event raises. Each handler takes the input from the ListBox, parses the value as a Double, and applies the value to the specified height-related property. The height values are also converted to a string and written to various TextBlock elements (definition of those elements is not shown in the selected XAML).


private void changeHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.Height = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}
private void changeMinHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.MinHeight = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}
private void changeMaxHeight(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
    Double sz1 = Double.Parse(li.Content.ToString());
    rect1.MaxHeight = sz1;
    rect1.UpdateLayout();
    txt1.Text= "ActualHeight is set to " + rect1.ActualHeight;
    txt2.Text= "Height is set to " + rect1.Height;
    txt3.Text= "MinHeight is set to " + rect1.MinHeight;
    txt4.Text= "MaxHeight is set to " + rect1.MaxHeight;
}


For the complete sample, see Height Properties Sample.

.NET Framework

Compatible con: 4, 3.5, 3.0

.NET Framework Client Profile

Compatible con: 4, 3.5 SP1

Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft