我想在用户按 F1 时显示帮助文件。如何停止显示默认帮助文件?我做了以下事情:
public static class HelpProvider
{
#region DependencyProperty [SourceProperty]
public static readonly DependencyProperty SourceProperty =
DependencyProperty.RegisterAttached("Source", typeof(string), typeof(HelpProvider),
new PropertyMetadata(OnSourcePropertyChanged));
public static string GetSource(DependencyObject obj)
{
return (string)obj.GetValue(SourceProperty);
}
public static void SetSource(DependencyObject obj, string value)
{
obj.SetValue(SourceProperty, value);
}
public static void OnSourcePropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue == null || !(e.NewValue is string)) return;
var element = sender as FrameworkElement;
if (element != null)
element.KeyDown += element_KeyDown;
}
#endregion
#region Method
static void element_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.F1) return;
e.Handled = true;
if (GetSource(sender as DependencyObject) != null)
{
ShowHelpFile(GetSource(sender as DependencyObject));
}
}
private static void ShowHelpFile(string helpContext)
{
if (!DesignerProperties.IsInDesignTool)
{
/* Putting the invoking in UIThreadAsync:
* http://stackoverflow.com/questions/808030/reentrancy-was-detected
*/
HtmlPage.Window.Invoke("OpenHelpWindow", new object[] { filePath });
}
}
#endregion
}
OpenHelpWindow
这是 JS 中打开一个窗口的方法有没有人有想法不显示默认帮助窗口,我很高兴在这里为新设计提供新想法?
谢谢