在 WPF 中使用 F1 帮助(CHM 格式)

发布于 2024-07-22 06:25:22 字数 1011 浏览 7 评论 0原文

我已经在 WPF 应用程序上工作了一段时间,现在是时候向其附加 CHM 格式的帮助文档了。

可惜! HelpProvider(在 Winforms 中显示 CHM 文件的标准方式)已经神奇地消失了,并且在 WPF 中没有对应的方式。 我一直在尝试使用 WindowsFormsHost 生成一个新控件,以便我可以实际显示帮助,但本质上它只是获取整个 UI 的控制权。

更详细一点:我有一个菜单项,我想在单击该菜单项时打开 CHM 文件。

首先,我设置了 WindowsFormsHost...

host = new System.Windows.Forms.Integration.WindowsFormsHost();
helpForm = new System.Windows.Forms.Control();
host.Child = helpForm;
host.Visibility = System.Windows.Visibility.Hidden;
this.grid1.Children.Add(host);

hp = new System.Windows.Forms.HelpProvider();
hp.HelpNamespace = "Somehelpfile.chm";
hp.SetHelpNavigator(helpForm, System.Windows.Forms.HelpNavigator.TableOfContents);

然后我说,瞧,展示你自己。

private void Help_Click(object sender, RoutedEventArgs e)
{
    host.Visibility = Visibility.Visible;
    helpForm.Show();
    hp.SetShowHelp(helpForm, true);
}  

我不太确定从这里开始哪里。 当我显示 helpForm 时,它会遮挡/覆盖现有的 UI,我得到的只是一个灰色的空 WPF 窗口,没有帮助文件。

有接受者吗?

I've been working on a WPF application for a while, and the time has come to attach the CHM format help document to it.

But alas! HelpProvider, the standard way to show CHM files in Winforms, has magically vanished and has no counterpart in WPF. I've been trying to use WindowsFormsHost to spawn a new control so I can actually display the help, but essentially it just grabs control of the entire UI.

A little more detail: I've got a menu item that I want to, when clicked, open up the CHM file.

First I set up the WindowsFormsHost...

host = new System.Windows.Forms.Integration.WindowsFormsHost();
helpForm = new System.Windows.Forms.Control();
host.Child = helpForm;
host.Visibility = System.Windows.Visibility.Hidden;
this.grid1.Children.Add(host);

hp = new System.Windows.Forms.HelpProvider();
hp.HelpNamespace = "Somehelpfile.chm";
hp.SetHelpNavigator(helpForm, System.Windows.Forms.HelpNavigator.TableOfContents);

And then I say, voila, reveal yourself.

private void Help_Click(object sender, RoutedEventArgs e)
{
    host.Visibility = Visibility.Visible;
    helpForm.Show();
    hp.SetShowHelp(helpForm, true);
}  

I'm not really sure of where to proceed from here. When I show the helpForm, it obscures / overrides the existing UI and all I get is a gray, empty WPF window with no help file.

Any takers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

梓梦 2024-07-29 06:25:22

如果您包含 System.Windows.Forms.dll,您还可以执行以下操作:

System.Windows.Forms.Help.ShowHelp(null, @"help.chm");

此外,还有一篇文章 此处介绍如何向 WPF 添加上下文相关的帮助系统。

If you include System.Windows.Forms.dll you can also do:

System.Windows.Forms.Help.ShowHelp(null, @"help.chm");

Also, there's an article here about adding a context sensitive help system to WPF.

破晓 2024-07-29 06:25:22

你可以说我疯了,但你就不能这样做:

System.Diagnostics.Process.Start(@"C:\path-to-chm-file.chm");

Call me crazy, but couldn't you just do:

System.Diagnostics.Process.Start(@"C:\path-to-chm-file.chm");
转角预定愛 2024-07-29 06:25:22

我正在尝试 WPF 轻松帮助,还提供基于关键词的上下文相关帮助。 到目前为止看起来不错。 我需要做的就是破解并写一些像样的帮助!

I am trying out Easy Help with WPF, which also addresses context sensitive help based on key words. So far it seems good. All I need to do is get cracking and write some decent help!

甜尕妞 2024-07-29 06:25:22

如何使用 Help 类而不是从外部打开文件

How about using the Help class instead of opening the file externally

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文