在 WPF 中使用 F1 帮助(CHM 格式)
我已经在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您包含 System.Windows.Forms.dll,您还可以执行以下操作:
此外,还有一篇文章 此处介绍如何向 WPF 添加上下文相关的帮助系统。
If you include System.Windows.Forms.dll you can also do:
Also, there's an article here about adding a context sensitive help system to WPF.
你可以说我疯了,但你就不能这样做:
Call me crazy, but couldn't you just do:
我正在尝试 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!
您可以使用 http://www.pinvoke.net/default.aspx/hhctrl.HtmlHelp< /a> 打开指定主题的 chm 帮助,并更好地控制 chm 窗口的显示方式。
You can use http://www.pinvoke.net/default.aspx/hhctrl.HtmlHelp to open chm help at specified topic and to have more control of how chm window shown.
如何使用 Help 类而不是从外部打开文件
How about using the Help class instead of opening the file externally