FrameworkElement.MaxWidth FrameworkElement.MaxWidth FrameworkElement.MaxWidth FrameworkElement.MaxWidth Property

定義

取得或設定元素的最大寬度限制。Gets or sets the maximum width constraint of the element.

public:
 property double MaxWidth { double get(); void set(double value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))]
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
public double MaxWidth { get; set; }
member this.MaxWidth : double with get, set
Public Property MaxWidth As Double

屬性值

項目的最大寬度 (以 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit) 為單位)。The maximum width of the element, in 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit). 預設值為 PositiveInfinityThe default value is PositiveInfinity. 這個值可以是等於或大於 0.0 的任何值。This value can be any value equal to or greater than 0.0. PositiveInfinity 也有效。PositiveInfinity is also valid.

備註

這是三個屬性上FrameworkElement指定寬度的資訊。This is one of three properties on FrameworkElement that specify width information. 其他兩種方式MinWidthWidthThe other two are MinWidth and Width. 如果這些值之間沒有衝突,實際寬度判斷的應用程式的順序是第一個MinWidth必須能被接受,然後MaxWidth,最後每一個位於範圍中,如果WidthIf there is a conflict between these values, the order of application for actual width determination is first MinWidth must be honored, then MaxWidth, and finally if each of these are within bounds, Width.

值的限制Double值會強制執行ValidateValueCallback機制。The value restrictions on the Double value are enforced by a ValidateValueCallback mechanism. 如果您嘗試設定無效的值,則會擲回執行階段例外狀況。If you attempt to set an invalid value, a run-time exception is thrown.

XAML Attribute UsageXAML Attribute Usage

<object MaxWidth="double"/>  
- or -  
<object MaxWidth="qualifiedDouble"/>  

XAML 值XAML Values

doubledouble
Double

字串表示法Double等於或大於 0.0 的值。String representation of a Double value equal to or greater than 0.0. 這會解譯為裝置獨立單位 (1/96 英吋)device-independent unit (1/96th inch)度量。This is interpreted as a 裝置獨立單位 (1/96 英吋)device-independent unit (1/96th inch) measurement. 字串不需要明確包含小數位數。Strings need not explicitly include decimal points. 執行個體的值1是可以接受的。For instance a value of 1 is acceptable.

相同Double套用範圍限制的屬性值一節中所述,不同之處在於您必須使用X:static 標記延伸來設定這個值為PositiveInfinityThe same Double range restrictions as mentioned in the Property Value section apply, except that you must use x:Static Markup Extension to set the value to be PositiveInfinity.

qualifiedDoublequalifiedDouble
A值,如上所述,後面接著一個的下列單位宣告字串: pxincmptA double value as described above, followed by one of the following unit declaration strings: px, in, cm, pt.

px (預設值) 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit)px (default) is 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit)

in 是英吋為單位;1in = = 96pxin is inches; 1in==96px

cm 是公釐。1cm==(96/2.54) 像素cm is centimeters; 1cm==(96/2.54) px

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

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field MaxWidthProperty
若要設定的中繼資料屬性 trueMetadata properties set to true AffectsMeasure

適用於