VisualElement.MinimumHeightRequest 屬性

定義

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

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

屬性值

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

備註

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

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

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

  image.MinimumHeightRequest = 20;
  Content = new StackLayout {
    Children {
      label,
      image
    }
  };
}

適用於