如何将滚动条添加到 wpf c# 中的文本框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36756935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 13:46:01  来源:igfitidea点击:

How do I add a scrollbar to a textbox in wpf c#

c#wpftextboxvisual-studio-2015

提问by John Douglas

I know it's pretty easy with windows forms but I have to use a wpf application so it's probably harder as I can't seem to find anything. Thanks

我知道使用 Windows 窗体很容易,但我必须使用 wpf 应用程序,所以它可能更难,因为我似乎找不到任何东西。谢谢

回答by Nejc Galof

The HorizontalScrollBarVisibilityand VerticalScrollBarVisibilityproperties are used to set horizontal and vertical scroll bars of a TextBox, The ScrollBarVisibility enumeration has four values – Disabled, Auto, Hidden, and Visible.

HorizontalScrollBarVisibilityVerticalScrollBarVisibility属性用于设置TextBox的水平和垂直滚动条,所述ScrollBarVisibility枚举有四个值- ,DisabledAutoHiddenVisible

<TextBox Name="TextBox"
         Width="300" Height="150"
         HorizontalScrollBarVisibility="Visible"
         VerticalScrollBarVisibility="Visible"
         TextWrapping="Wrap" >           
</TextBox>