[英]How can I get the same behavior in a WPF control/set of controls as that of HTML with links to other page content?
In HTML I can add a link <a href="#tagID">
that will jump to another tag with that id (ie <div id="tagID">
). 在HTML中,我可以添加链接
<a href="#tagID">
,该链接将跳转到具有该ID的另一个标签(即<div id="tagID">
)。
In my WPF program I have a list of GroupBox
es, currently inside a ScrollViewer
. 在我的WPF程序中,我有一个
GroupBox
列表,当前位于ScrollViewer
。 I want to be able to somehow click a link or button or have a way that will scroll the appropriate GroupBox
to the top, much the same way as linking to IDs on an HTML page. 我希望能够以某种方式单击链接或按钮,或者具有一种将适当的
GroupBox
滚动到顶部的方式,与链接到HTML页面上的ID的方式几乎相同。
How can I get this functionality using WPF? 如何使用WPF获得此功能? Is there a control that will do this?
有控件可以做到这一点吗?
Use the FrameworkElement.BringIntoView()
method: 使用
FrameworkElement.BringIntoView()
方法:
<Button Content="Go To GroupBox 10"
Click="Button_Click"/>
Code Behind: 背后的代码:
private void Button_Click(object sender, RoutedEventArgs e)
{
GroupBox10.BringIntoView();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.