|
Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
|
Traduzione
Originale
|
Proprietà FrameworkElement.Width
Spazio dei nomi: System.Windows
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS per XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)] [TypeConverterAttribute(typeof(LengthConverter))] public double Width { get; set; }
<object Width="double"/> - or – <object Width ="qualifiedDouble"/> - or - <object Width ="Auto"/>
Valor XAML
Valore proprietà
Tipo: System.Double<Canvas Height="200" MinWidth="200" Background="#b0c4de" VerticalAlignment="Top" HorizontalAlignment="Center" Name="myCanvas"> <Rectangle HorizontalAlignment="Center" Canvas.Top="50" Canvas.Left="50" Name="rect1" Fill="#4682b4" Width="100" Height="100"/> </Canvas> ... <TextBlock Grid.Row="1" Grid.Column="0" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle Width:</TextBlock> <ListBox Grid.Column="1" Grid.Row="1" Margin="10,0,0,0" Width="50" Height="50" SelectionChanged="changeWidth"> <ListBoxItem>25</ListBoxItem> <ListBoxItem>50</ListBoxItem> <ListBoxItem>75</ListBoxItem> <ListBoxItem>100</ListBoxItem> <ListBoxItem>125</ListBoxItem> <ListBoxItem>150</ListBoxItem> <ListBoxItem>175</ListBoxItem> <ListBoxItem>200</ListBoxItem> <ListBoxItem>225</ListBoxItem> <ListBoxItem>250</ListBoxItem> </ListBox> <TextBlock Grid.Row="1" Grid.Column="2" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle MinWidth:</TextBlock> <ListBox Grid.Column="3" Grid.Row="1" Margin="10,0,0,0" Width="50" Height="50" SelectionChanged="changeMinWidth"> <ListBoxItem>25</ListBoxItem> <ListBoxItem>50</ListBoxItem> <ListBoxItem>75</ListBoxItem> <ListBoxItem>100</ListBoxItem> <ListBoxItem>125</ListBoxItem> <ListBoxItem>150</ListBoxItem> <ListBoxItem>175</ListBoxItem> <ListBoxItem>200</ListBoxItem> <ListBoxItem>225</ListBoxItem> <ListBoxItem>250</ListBoxItem> </ListBox> <TextBlock Grid.Row="1" Grid.Column="4" Margin="10,0,0,0" TextWrapping="Wrap">Set the Rectangle MaxWidth:</TextBlock> <ListBox Grid.Column="5" Grid.Row="1" Margin="10,0,0,0" Width="50" Height="50" SelectionChanged="changeMaxWidth"> <ListBoxItem>25</ListBoxItem> <ListBoxItem>50</ListBoxItem> <ListBoxItem>75</ListBoxItem> <ListBoxItem>100</ListBoxItem> <ListBoxItem>125</ListBoxItem> <ListBoxItem>150</ListBoxItem> <ListBoxItem>175</ListBoxItem> <ListBoxItem>200</ListBoxItem> <ListBoxItem>225</ListBoxItem> <ListBoxItem>250</ListBoxItem> </ListBox>
private void changeWidth(object sender, SelectionChangedEventArgs args) { ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem); Double sz1 = Double.Parse(li.Content.ToString()); rect1.Width = sz1; rect1.UpdateLayout(); txt1.Text = "ActualWidth is set to " + rect1.ActualWidth; txt2.Text = "Width is set to " + rect1.Width; txt3.Text = "MinWidth is set to " + rect1.MinWidth; txt4.Text = "MaxWidth is set to " + rect1.MaxWidth; } private void changeMinWidth(object sender, SelectionChangedEventArgs args) { ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem); Double sz1 = Double.Parse(li.Content.ToString()); rect1.MinWidth = sz1; rect1.UpdateLayout(); txt1.Text = "ActualWidth is set to " + rect1.ActualWidth; txt2.Text = "Width is set to " + rect1.Width; txt3.Text = "MinWidth is set to " + rect1.MinWidth; txt4.Text = "MaxWidth is set to " + rect1.MaxWidth; } private void changeMaxWidth(object sender, SelectionChangedEventArgs args) { ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem); Double sz1 = Double.Parse(li.Content.ToString()); rect1.MaxWidth = sz1; rect1.UpdateLayout(); txt1.Text = "ActualWidth is set to " + rect1.ActualWidth; txt2.Text = "Width is set to " + rect1.Width; txt3.Text = "MinWidth is set to " + rect1.MinWidth; txt4.Text = "MaxWidth is set to " + rect1.MaxWidth; }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (ruoli di base del server non supportati), Windows Server 2008 R2 (ruoli di base del server supportati con SP1 o versione successiva, Itanium non supportato)
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.