简体   繁体   English

如何在WPF控件/控件集中获得与具有链接到其他页面内容的HTML相同的行为?

[英]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.

相关问题 如何将ListView控件置于WPF中的其他控件之上 - How I can bring ListView control in top of other controls in WPF 如何更好地一次控制多个控件的行为? - How can I better control behavior on multiple controls at once? 如何阻止移动的用户控件与其他相同类型的用户控件相交? - How can I stop a moving user control from intersecting with other user controls of the same type? C# WPF:如何从另一个页面访问页面控件以获取 textbox.text - C# WPF : how can i access page controls from another page to get textbox.text WPF-绑定到同一控件实例的两个用户控件的内容 - WPF - Content of two user controls bound to same instance of control 用户控制其他开发人员可以向其添加控件并“继承”我控件上所有控件的行为 - user control that other developers can add controls to it and “inherit” the behavior of all controls on my control 如何在绑定到同一数据源的单独表单上获得两个控件以相互更新? - How can I get two controls on separate forms bound to the same datasource to update each other? 如何在WPF中获取TreeViewItem的内容? - How I can get content of TreeViewItem in WPF? 如何基于绑定列表构建包含其他控件的 WPF 控件 - How to build a WPF control containing other controls based on a bound list 如何在 wpf 的内容控件中显示视图 - How can I display view inside content control in wpf
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM