c# – NavigationWindow单击声音

前端之家收集整理的这篇文章主要介绍了c# – NavigationWindow单击声音前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个 WPF应用程序,它使用导航窗口和框架在xaml页面之间导航.每次它在页面之间发出咔嗒声.有没有办法禁用它?

到目前为止,我试过这个:

namespace FrameTesting
{
public partial class MainWindow : NavigationWindow
{
    private const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21;
    private const int SET_FEATURE_ON_THREAD = 0x00000001;
    private const int SET_FEATURE_ON_PROCESS = 0x00000002;
    private const int SET_FEATURE_IN_REGISTRY = 0x00000004;
    private const int SET_FEATURE_ON_THREAD_LOCALMACHINE = 0x00000008;
    private const int SET_FEATURE_ON_THREAD_INTRANET = 0x00000010;
    private const int SET_FEATURE_ON_THREAD_TRUSTED = 0x00000020;
    private const int SET_FEATURE_ON_THREAD_INTERNET = 0x00000040;
    private const int SET_FEATURE_ON_THREAD_RESTRICTED = 0x00000080;

    public MainWindow()
    {
        int feature = FEATURE_DISABLE_NAVIGATION_SOUNDS;
        CoInternetSetFeatureEnabled(feature,SET_FEATURE_ON_PROCESS,true);
        InitializeComponent();
    }

    [DllImport("urlmon.dll")]
    [PreserveSig]
    [return: MarshalAs(UnmanagedType.Error)]
    static extern int CoInternetSetFeatureEnabled(
         int FeatureEntry,[MarshalAs(UnmanagedType.U4)] int dwFlags,bool fEnable);
}

}

解决方法

您想要的功能称为 CoInternetSetFeatureEnabled,您可以在接受的答案 to this question中找到一些其他信息.

由于WPF在引擎盖下使用WebBrowser控件,因此它也适用于Frame控件.

猜你在找的C#相关文章