WrapPanel.ItemHeight Propriété

Définition

Obtient ou définit une valeur qui spécifie la hauteur de tous les éléments contenus dans un WrapPanel.

public:
 property double ItemHeight { double get(); void set(double value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))]
public double ItemHeight { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))>]
member this.ItemHeight : double with get, set
Public Property ItemHeight As Double

Valeur de propriété

Double qui représente la hauteur uniforme de tous les éléments contenus dans le WrapPanel. La valeur par défaut est NaN.

Attributs

Exemples

L’exemple suivant montre comment définir la ItemHeight propriété dans XAML (Extensible Application Markup Language).

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" WindowTitle="WrapPanel Properties Sample">
  <Border HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="2">
        <WrapPanel Orientation="Horizontal" Background="Azure" ItemWidth="25" ItemHeight="25" Height="200" Width="200">
            <Button Width="200">Button 1</Button>
            <Button>Button 2</Button>
            <Button>Button 3</Button>
        </WrapPanel>
  </Border>    
</Page>

L’exemple suivant montre comment définir la propriété à l’aide ItemHeight de code.


// Create the application's main window
mainWindow = gcnew System::Windows::Window();
mainWindow->Title = "WrapPanel Sample";


// Instantiate a new WrapPanel and set properties
myWrapPanel = gcnew WrapPanel();
myWrapPanel->Background = Brushes::Azure;
myWrapPanel->Orientation = Orientation::Horizontal;
myWrapPanel->ItemHeight = 25;

myWrapPanel->ItemWidth = 75;
myWrapPanel->Width = 150;
myWrapPanel->HorizontalAlignment = HorizontalAlignment::Left;
myWrapPanel->VerticalAlignment = VerticalAlignment::Top;

// Define 3 button elements. Each button is sized at width of 75, so the third button wraps to the next line.
btn1 = gcnew Button();
btn1->Content = "Button 1";
btn2 = gcnew Button();
btn2->Content = "Button 2";
btn3 = gcnew Button();
btn3->Content = "Button 3";

// Add the buttons to the parent WrapPanel using the Children.Add method.
myWrapPanel->Children->Add(btn1);
myWrapPanel->Children->Add(btn2);
myWrapPanel->Children->Add(btn3);

// Add the WrapPanel to the MainWindow as Content
mainWindow->Content = myWrapPanel;
mainWindow->Show();

// Create the application's main window
mainWindow = new System.Windows.Window();
mainWindow.Title = "WrapPanel Sample";


// Instantiate a new WrapPanel and set properties
myWrapPanel = new WrapPanel();
myWrapPanel.Background = System.Windows.Media.Brushes.Azure;
myWrapPanel.Orientation = Orientation.Horizontal;
myWrapPanel.Width = 200;
myWrapPanel.HorizontalAlignment = HorizontalAlignment.Left;
myWrapPanel.VerticalAlignment = VerticalAlignment.Top;

// Define 3 button elements. The last three buttons are sized at width 
// of 75, so the forth button wraps to the next line.
btn1 = new Button();
btn1.Content = "Button 1";
btn1.Width = 200;
btn2 = new Button();
btn2.Content = "Button 2";
btn2.Width = 75;
btn3 = new Button();
btn3.Content = "Button 3";
btn3.Width = 75;
btn4 = new Button();
btn4.Content = "Button 4";
btn4.Width = 75;

// Add the buttons to the parent WrapPanel using the Children.Add method.
myWrapPanel.Children.Add(btn1);
myWrapPanel.Children.Add(btn2);
myWrapPanel.Children.Add(btn3);
myWrapPanel.Children.Add(btn4);

// Add the WrapPanel to the MainWindow as Content
mainWindow.Content = myWrapPanel;
mainWindow.Show();
WindowTitle = "WrapPanel Sample"

' Instantiate a new WrapPanel and set properties
Dim myWrapPanel As New WrapPanel()
myWrapPanel.Background = Brushes.Azure
myWrapPanel.Orientation = Orientation.Horizontal

myWrapPanel.Width = 200
myWrapPanel.HorizontalAlignment = Windows.HorizontalAlignment.Left
myWrapPanel.VerticalAlignment = Windows.VerticalAlignment.Top

' Define 3 button elements. The last three buttons are sized at width 
' of 75, so the forth button wraps to the next line.
Dim btn1 As New Button()
btn1.Content = "Button 1"
btn1.Width = 200
Dim btn2 As New Button()
btn2.Content = "Button 2"
btn2.Width = 75
Dim btn3 As New Button()
btn3.Content = "Button 3"
btn3.Width = 75
Dim btn4 As New Button()
btn4.Content = "Button 4"
btn4.Width = 75

' Add the buttons to the parent WrapPanel using the Children.Add method.
myWrapPanel.Children.Add(btn1)
myWrapPanel.Children.Add(btn2)
myWrapPanel.Children.Add(btn3)
myWrapPanel.Children.Add(btn4)

' Add the WrapPanel to the Page as Content
Me.Content = myWrapPanel
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" WindowTitle="WrapPanel Sample">
  <Border HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="2">
        <WrapPanel Background="LightBlue" Width="200" Height="100">
            <Button Width="200">Button 1</Button>
            <Button>Button 2</Button>
            <Button>Button 3</Button>
            <Button>Button 4</Button>
        </WrapPanel>
  </Border>    
</Page>

Remarques

Si cette propriété n’est pas définie (ou si elle est définie sur Auto en XAML ou Double.NaN sur dans le code), la taille de la partition de disposition est égale à la taille souhaitée de l’élément enfant.

Sa propriété height peut être définie explicitement pour un élément enfant d’un WrapPanel . ItemHeight spécifie la taille de la partition de disposition réservée par pour l’élément WrapPanel enfant. Par conséquent, ItemHeight est prioritaire sur la hauteur d’un élément.

Utilisation d'attributs XAML

<object ItemHeight="double"/>  
- or -  
<object ItemHeight="qualifiedDouble"/>  
- or -  
<object ItemHeight="Auto"/>  

Valeurs XAML

double
Double

Représentation sous forme de chaîne d’une Double valeur égale ou supérieure à 0.0034 , mais égale ou inférieure 160000à . Une valeur non qualifiée est mesurée en pixels indépendants de l’appareil. Les chaînes n’ont pas besoin d’inclure explicitement des décimales.

qualifiedDouble
Valeur double comme décrit ci-dessus, (à l’exception Autode ) suivie de l’un des spécificateurs d’unité suivants : px, in, cm, pt.

px (valeur par défaut) est des unités indépendantes de l’appareil (1/96e pouce par unité)

in est en pouces ; 1in==96px

cm est centimètres; 1cm==(96/2.54) px

pt est des points ; 1pt==(96/72) px

Auto
Provoque la détermination automatique de la hauteur de ligne à partir des caractéristiques de police actuelles. Équivaut à une valeur de propriété de NaN.

Informations sur les propriétés de dépendance

Champ Identificateur ItemHeightProperty
Propriétés de métadonnées définies sur true AffectsMeasure

S’applique à

Voir aussi