代码拉取完成,页面将自动刷新
帮助模块:HelpProvider想用的可以去msdn上查一查,不过这货是windows.forms里的东西,不能在wpf里面用,坑爹呢啊这是,不过在网上找到了一个高人应该算是在wpf里重写了这个HelpProvider,这就让我们写wpf的也可以好好用了,代码经过测试,妥妥的。
namespace ContextSensitiveHelp
{
/// <summary>
/// This class provides the ability to easily attach Help functionality to Framework elements.
/// To use it, you need to add a reference to the HelpProvider in your XAML.
/// The FilenameProperty specifies the name of the help file, and the KeywordProperty specifies the keyword to be used with the search.
/// </summary>
/// <remarks>
/// The FilenameProperty can be at a higher level of the visual tree than the KeywordProperty, so you don't need to set the filename each time.
/// </remarks>
static class HelpProvider
{
static HelpProvider()
{
CommandManager.RegisterClassCommandBinding(typeof(FrameworkElement),
new CommandBinding(ApplicationCommands.Help,
new ExecutedRoutedEventHandler(Executed),
new CanExecuteRoutedEventHandler(CanExecute)));
}
#region Filename
/// <summary>
/// Filename Attached Dependency Property
/// </summary>
public static readonly DependencyProperty FilenameProperty =
DependencyProperty.RegisterAttached("Filename", typeof(string), typeof(HelpProvider));
/// <summary>
/// Gets the Filename property.
/// </summary>
public static string GetFilename(DependencyObject d)
{
return (string)d.GetValue(FilenameProperty);
}
/// <summary>
/// Sets the Filename property.
/// </summary>
public static void SetFilename(DependencyObject d, string value)
{
d.SetValue(FilenameProperty, value);
}
#endregion
#region Keyword
/// <summary>
/// Keyword Attached Dependency Property
/// </summary>
public static readonly DependencyProperty KeywordProperty =
DependencyProperty.RegisterAttached("Keyword", typeof(string), typeof(HelpProvider));
/// <summary>
/// Gets the Keyword property.
/// </summary>
public static string GetKeyword(DependencyObject d)
{
return (string)d.GetValue(KeywordProperty);
}
/// <summary>
/// Sets the Keyword property.
/// </summary>
public static void SetKeyword(DependencyObject d, string value)
{
d.SetValue(KeywordProperty, value);
}
#endregion
#region Event
private static void CanExecute(object sender, CanExecuteRoutedEventArgs args)
{
FrameworkElement el = sender as FrameworkElement;
if (el != null)
{
string fileName = FindFilename(el);
if (!string.IsNullOrEmpty(fileName))
args.CanExecute = true;
}
}
private static void Executed(object sender, ExecutedRoutedEventArgs args)
{
// Call ShowHelp.
DependencyObject parent = args.OriginalSource as DependencyObject;
string keyword = GetKeyword(parent);
if (!string.IsNullOrEmpty(keyword))
{
System.Windows.Forms.Help.ShowHelp(null, FindFilename(parent), keyword);
}
else
{
System.Windows.Forms.Help.ShowHelp(null, FindFilename(parent));
}
}
private static string FindFilename(DependencyObject sender)
{
if (sender != null)
{
string fileName = GetFilename(sender);
if (!string.IsNullOrEmpty(fileName))
return fileName;
return FindFilename(VisualTreeHelper.GetParent(sender));
}
return null;
}
#endregion
}
}
不解释,自己看,毫无压力。在前台页面里加上下面这句话就好
xmlns:h="clr-namespace:ContextSensitiveHelp"
h:HelpProvider.Filename="Help1.chm" h:HelpProvider.Keyword="button.html"
同时一定要把帮助文档放到bin\debug里面去,不一定非得是.chm的,word也可以的。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。