簡體   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?

在HTML中,我可以添加鏈接<a href="#tagID"> ,該鏈接將跳轉到具有該ID的另一個標簽(即<div id="tagID"> )。

在我的WPF程序中,我有一個GroupBox列表,當前位於ScrollViewer 我希望能夠以某種方式單擊鏈接或按鈕,或者具有一種將適當的GroupBox滾動到頂部的方式,與鏈接到HTML頁面上的ID的方式幾乎相同。

如何使用WPF獲得此功能? 有控件可以做到這一點嗎?

使用FrameworkElement.BringIntoView()方法:

<Button Content="Go To GroupBox 10"
        Click="Button_Click"/>

背后的代碼:

private void Button_Click(object sender, RoutedEventArgs e)
{
    GroupBox10.BringIntoView();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM