问题
Is there a way to create a ScrollViewer which only allows content to scroll vertically? The horizontal (width) must be constrained in the same manner as a StackPanel's width is constrained to its parent (when HorizontalAlignment=Stretch).
I have a resizable window which contains content I want to allow to scroll vertically. The window contains a ScrollViewer. Inside there is a lot of TextBoxs (a data entry form). When I type lots of text in a TextBox, the control just keeps growing to the right, and off the window. If I use a StackPanel instead of a ScrollViewer, then the size of the TextBox remains the same no matter how much text is in there. (but then no vertical scrolling).
I cant set a hard-coded Width because the window is resizable.
So basically I want to constrain the ScrollViewer from growing in the Horizontal direction.
Thanks
回答1:
Try setting
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
来源:https://stackoverflow.com/questions/7682319/silverlight-vertical-only-scrollviewer