导出 (0) 打印
全部展开
信息
您所需的主题如下所示。但此主题未包含在此库中。

TextBox.HorizontalScrollBarVisibility 属性

2013/12/13

获取或设置水平滚动条的可见性。

Namespace:  System.Windows.Controls
程序集:  System.Windows(位于 System.Windows.dll 中)
XMLNS for XAML: 未映射到 xmlns。

public ScrollBarVisibility HorizontalScrollBarVisibility { get; set; }
<TextBox HorizontalScrollBarVisibility="scrollBarVisibilityValue"/>

XAML 值

scrollBarVisibilityValue

ScrollBarVisibility 枚举的一个已命名常量,例如 Auto

属性值

类型: System.Windows.Controls.ScrollBarVisibility
水平滚动条的可见性。 默认值为 Hidden

如果 HorizontalScrollBarVisibility 设置为 Disabled,则文本框不会水平滚动。

下面的代码段演示如何可以在 XAML 和代码中使用 HorizontalScrollBarVisibility 属性。


<StackPanel>
    <TextBox Margin="20,20,0,0" Text="A text box that demonstrates TextWrapping, TextAlignment, MaxLength, and AcceptsReturn" 
             Width="300" Height="150" TextWrapping="Wrap" TextAlignment="Center" MaxLength="500" AcceptsReturn="True" />
    <TextBox Margin="20,20,0,0" Text="A text box that demonstrates HorizontalScrollBarVisibility and VerticalScrollBarVisibility" 
             Width="300" Height="150" AcceptsReturn="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" />
</StackPanel>



public Page()
{
    InitializeComponent();
    CreateControls();
}

private void CreateControls()
{
    //Create stack panel
    StackPanel MyStackPanel = new StackPanel();

    //Create the first text box
    TextBox MyTB1 = new TextBox();
    MyTB1.Width = 300;
    MyTB1.Height = 150;
    MyTB1.Text = "A text box that demonstrates TextWrapping, TextAlignment, MaxLength and AcceptsReturn";
    MyTB1.TextWrapping = TextWrapping.Wrap;
    MyTB1.TextAlignment = TextAlignment.Center;
    MyTB1.MaxLength = 500;
    MyTB1.AcceptsReturn = true;
    MyTB1.Margin = new Thickness(20, 20, 0, 0);

    //Create the second text box
    TextBox MyTB2 = new TextBox();
    MyTB2.Margin = new Thickness(20, 20, 0, 0);
    MyTB2.Text = "A text box that demonstrates HorizontalScrollBarVisibility and VerticalScrollBarVisibility";
    MyTB2.Width = 300;
    MyTB2.Height = 150;
    MyTB2.AcceptsReturn = true;
    MyTB2.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
    MyTB2.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;

    //Add the text boxes to the stack panel
    MyStackPanel.Children.Add(MyTB1);
    MyStackPanel.Children.Add(MyTB2);
    this.Content = MyStackPanel;
}


Windows Phone OS

受以下版本支持: 8.0, 7.1, 7.0

Windows Phone

显示:
© 2014 Microsoft