0

ユーザーが 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 のメソッドです。デフォルトのヘルプ ウィンドウを表示しないというアイデアはありましたか?新しいデザインの新しいアイデアをここに紹介できれば幸いです。

ありがとう

4

1 に答える 1

0

これは重複した質問である可能性があります。あなたの答えになるかもしれないので、次の前の質問をチェックしてください:ブラウザのデフォルトのヘルプ機能を無効にする方法

ただし、一貫した方法で複数のブラウザーで F1 をオーバーライドしようとすると問題が発生するため、別の方法でヘルプを提供する方がよい場合があります。

于 2013-09-24T12:31:59.980 に答える