如何将滚动条添加到窗口在C# [英] How to Add a Scrollbar to Window in C#

查看:231
本文介绍了如何将滚动条添加到窗口在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个窗口,如下所示:

I have created a window as follows:

Window myWindow = new Window();



我如何添加一个垂直滚动条来此Windows,使滚动条如果身高才可见,是不是足够大,以显示所有的元素

How can I add a Vertical Scroll Bar to this Windows and make the Scroll Bar only visible if the Height isn't large enough to show all the elements.

推荐答案

您可以添加的的ScrollViewer 元素到你的窗口,把必要的控制进入的的ScrollViewer 的控制。

You could add a ScrollViewer element to your window and put the necessary controls into the ScrollViewer control.

<ScrollViewer VerticalScrollBarVisibility="Auto">
    ...
</ScrollViewer>



或者,如果你想在代码代码隐藏文件,你可以写

Or if you want to code it in the code-behind file you could write

ScrollViewer viewer = new ScrollViewer();
viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
// append scroll viewer to window

这篇关于如何将滚动条添加到窗口在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆