VisualElement.MinimumWidthRequest 屬性

定義

取得或設定值,這個值會覆寫項目在配置期間要求的最小寬度。

public double MinimumWidthRequest { get; set; }
member this.MinimumWidthRequest : double with get, set

屬性值

元素所需的最小寬度。 預設值為 -1。

備註

MinimumWidthRequest 是用來藉由設定最小寬度屬性來覆寫呼叫 GetSizeRequest(Double, Double) 的結果。 這會導致溢位處理在未設定大小下限的專案之前,將此元素壓縮成其最小寬度。

下列範例會設定 MinimumWidthRequest,讓影像縮小其正常大小。

void Build (string veryLongString)
{
  var label = new Label {Text = veryLongString};
  var image = new Image {Source = "image500x500.png"};

  image.MinimumWidthRequest = 20;
  Content = new StackLayout {
    Orientation = StackOrientation.Horizontal,
    Children {
      label,
      image
    }
  };
}

適用於