WrapPanel.ItemWidth Eigenschaft

Definition

Ruft einen Wert ab, der die Breite sämtlicher Elemente in einem WrapPanel angibt, oder legt diesen fest.Gets or sets a value that specifies the width of all items that are contained within a WrapPanel.

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

Eigenschaftswert

Ein Double, das die einheitliche Breite aller Elemente innerhalb des WrapPanel darstellt.A Double that represents the uniform width of all items that are contained within the WrapPanel. Der Standardwert ist NaNsein.The default value is NaN.

Attribute

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie die ItemWidth -Eigenschaft Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML)in festgelegt wird.The following example demonstrates how to set the ItemWidth property in Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML).

<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>

Im folgenden Beispiel wird veranschaulicht, wie die ItemWidth -Eigenschaft mithilfe von Code festgelegt wird.The following example demonstrates how to set the ItemWidth property by using 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>

Hinweise

Wenn diese Eigenschaft nicht festgelegt ist (oder wenn Sie Auto auf in Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) oder Double.NaN auf in Code festgelegt ist), ist die Größe der Layoutpartition gleich DesiredSize der des untergeordneten Elements.If this property is not set (or if it is set to Auto in Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) or to Double.NaN in code), the size of the layout partition is equal to the DesiredSize of the child element.

Für ein untergeordnetes Element WrapPanel einer kann die Width-Eigenschaft explizit festgelegt sein.A child element of a WrapPanel may have its width property set explicitly. ItemWidthGibt die Größe der Layoutpartition an, die vom WrapPanel für das untergeordnete Element reserviert wird.ItemWidth specifies the size of the layout partition that is reserved by the WrapPanel for the child element. Folglich hat Vorrang vor ItemWidth der eigenen Breite eines Elements.As a result, ItemWidth takes precedence over an element's own width.

Verwendung von XAML-AttributenXAML Attribute Usage

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

XAML-WerteXAML Values

doubledouble
Double

Zeichen folgen Darstellung eines Double Werts, der 0.0034 größer oder gleich, aber gleich oder kleiner als 160000ist.String representation of a Double value equal to or greater than 0.0034 but equal to or less than 160000. Ein nicht qualifizierter Wert wird in geräteunabhängigen Pixeln gemessen.An unqualified value is measured in device independent pixels. Zeichen folgen müssen nicht explizit Dezimalstellen enthalten.Strings need not explicitly include decimal points.

qualifiedDoublequalifiedDouble
Ein doppelter Wert Auto, wie oben beschrieben (ausgenommen), gefolgt von einem der folgenden Einheits spezifiken: in px,, cm, pt.A double value as described above, (excepting Auto) followed by one of the following unit specifiers: px, in, cm, pt.

px(Standard) istGeräteunabhängige Einheiten (1/96 Zoll pro Einheit)device-independent units (1/96th inch per unit)px (default) is Geräteunabhängige Einheiten (1/96 Zoll pro Einheit)device-independent units (1/96th inch per unit)

inist Zoll; 1In = = 96pxin is inches; 1in==96px

cmist Zentimeter; 1cm = = (96/2,54) pxcm is centimeters; 1cm==(96/2.54) px

ptist Punkte 1pt = = (96/72) pxpt is points; 1pt==(96/72) px

AutoAuto
Bewirkt, dass die Zeilenhöhe automatisch anhand der aktuellen Schriftart Merkmale bestimmt wird.Causes the line height is determined automatically from the current font characteristics. Entspricht einem-Eigenschafts Wert NaNvon.Equivalent to a property value of NaN.

Informationen zur AbhängigkeitseigenschaftDependency Property Information

BezeichnerfeldIdentifier field ItemWidthProperty
Metadateneigenschaften auf true festgelegtMetadata properties set to true AffectsMeasure

Gilt für:

Siehe auch