使用Scrollviewer实现Scrollbar(HSCROLL/VSCROLL) [英] Implementing Scrollbar(HSCROLL/VSCROLL) using Scrollviewer

查看:150
本文介绍了使用Scrollviewer实现Scrollbar(HSCROLL/VSCROLL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用WPF应用程序,该应用程序显示一个窗口,我需要在窗口中提供滚动条(因为它无法容纳文本内容),因此最好使用水平滚动条.

Hi All,

I am working in WPF Application, which displays a window, I need to provide scroll bar in my window(because it can''t fit textual content) a Horizontal Scrollbar is desirable.

<ScrollViewer Height="203" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Grid.Row="0" Grid.Column="0" Margin="5,5,5,5">
    <wfi:WindowsFormsHost >
        <wf:DataGridView x:Name="dataGridView1" >
        </wf:DataGridView>
    </wfi:WindowsFormsHost>
</ScrollViewer>

but on implementing above code I am unable to obtain scrollbar(Horizontal as well as vertical scrollbar), 
how can I use scrollviewer to implement scrollbar in my module.
Also, implementing HorizontalScrollbarVisibility as mentioned below, had the same effect.

<ScrollViewer  Width="200" HorizontalScrollBarVisibility="Auto" Grid.Column="0" Margin="0,0,0,5">
    <wfi:WindowsFormsHost>
        <wf:DataGridView x:Name="dataGridView2">
        </wf:DataGridView>
    </wfi:WindowsFormsHost>
</ScrollViewer>



我正在使用Windows 7 O/S(SP1).


提前谢谢.

问候,
Samanth_90



I am using Windows 7 O/S(SP1).


Thanks in advance.

With regards,
Samanth_90

推荐答案

不幸的是,在WPF滚动查看器中无法使用winformshost. Winforms控件呈现在WPF元素的顶部,因此控件的边界未在滚动查看器容器中注册.

http://social.msdn.microsoft.com/Forums/是/wpf/thread/d7a27149-cb12-4819-be77-f01e426aae87 [ http://msdn.microsoft.com/en-us/library/ms744952.aspx [ ^ ]
Unfortunately using a winformshost will not be possible with a WPF scrollviewer. The winforms control is rendered on top of WPF elements and so the boundries of the control are not registered in the scroll viewer container.

http://social.msdn.microsoft.com/Forums/is/wpf/thread/d7a27149-cb12-4819-be77-f01e426aae87[^]

http://msdn.microsoft.com/en-us/library/ms744952.aspx[^]


这篇关于使用Scrollviewer实现Scrollbar(HSCROLL/VSCROLL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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