TextBox.MinLines 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定可看見的最小行數。
public:
property int MinLines { int get(); void set(int value); };
public int MinLines { get; set; }
member this.MinLines : int with get, set
Public Property MinLines As Integer
屬性值
可看見的最小行數。 預設值是 1。
例外狀況
範例
下列範例示範如何建立 TextBoxMinLines 值為 1 的 。
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<TextBox
Text="Initial text in TextBox"
Width="200"
TextAlignment="Center"
TextWrapping="Wrap"
MaxLength="500"
MinLines="1"
MaxLines="5" />
</StackPanel>
</Page>
StackPanel myStackPanel = new StackPanel();
//Create TextBox
TextBox myTextBox = new TextBox();
myTextBox.Width = 200;
// Put some initial text in the TextBox.
myTextBox.Text = "Initial text in TextBox";
// Set the maximum characters a user can manually type
// into the TextBox.
myTextBox.MaxLength = 500;
myTextBox.MinLines = 1;
// Set the maximum number of lines the TextBox will expand to
// accomidate text. Note: This does not constrain the amount of
// text that can be typed. To do that, use the MaxLength property.
myTextBox.MaxLines = 5;
// The text typed into the box is aligned in the center.
myTextBox.TextAlignment = TextAlignment.Center;
// When the text reaches the edge of the box, go to the next line.
myTextBox.TextWrapping = TextWrapping.Wrap;
myStackPanel.Children.Add(myTextBox);
this.Content = myStackPanel;
Dim myStackPanel As New StackPanel()
'Create TextBox
Dim myTextBox As New TextBox()
myTextBox.Width = 200
' Put some initial text in the TextBox.
myTextBox.Text = "Initial text in TextBox"
' Set the maximum characters a user can manually type
' into the TextBox.
myTextBox.MaxLength = 500
myTextBox.MinLines = 1
' Set the maximum number of lines the TextBox will expand to
' accomidate text. Note: This does not constrain the amount of
' text that can be typed. To do that, use the MaxLength property.
myTextBox.MaxLines = 5
' The text typed into the box is aligned in the center.
myTextBox.TextAlignment = TextAlignment.Center
' When the text reaches the edge of the box, go to the next line.
myTextBox.TextWrapping = TextWrapping.Wrap
myStackPanel.Children.Add(myTextBox)
Me.Content = myStackPanel
備註
取得這個屬性會傳回 的目前值 MinLines 。 如果可見行數目小於 所 MinLines 指定的值,設定此屬性會導致文字方塊調整大小。
Height如果在 上 TextBox 明確設定 屬性,則會 MaxLines 忽略 和 MinLines 屬性值。
相依性屬性資訊
識別碼欄位 | MinLinesProperty |
中繼資料屬性設定為 true |
AffectsMeasure |