0

我想完成他们在Modern UI for WPF中所做的事情。我有MainWindow : NavigationWindow,它的来源是页面/main.xaml,我的代码如下所示:

public partial class main : Page
{
    public main()
    {
        InitializeComponent();
    }

    private void settings_Click(object sender, RoutedEventArgs e)
    {
        settings settingsmenu = new settings();
        this.NavigationService.Navigate(settingsmenu);
    }
}

问题是,当我切换页面时,会出现烦人的声音。我认为它被命名为“导航开始”。我可以阻止它播放吗?还是有另一种切换页面的方法,不能播放?提前致谢。

(对不起,如果这个问题很愚蠢,但我是 WPF 新手)

4

1 回答 1

0

这是一个小解决方法。我在这里找到的原始来源:http: //social.msdn.microsoft.com/Forums/vstudio/en-us/843677f4-8f0b-46cb-986c-92e8042d0707/stupid-problem-with-webbrowser-control

using System.Windows;
using System.Windows.Controls;
using Microsoft.Win32;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        private RegistryKey regKeyCurrentUser;
        private RegistryKey regSubKeyCurrent;

        public Page1()
        {
            InitializeComponent();
        }

        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var page2 = new Page2();
            this.NavigationService.Navigate(page2);
        }

        private void Page1_OnLoaded(object sender, RoutedEventArgs e)
        {
            regKeyCurrentUser = Registry.CurrentUser;
            regSubKeyCurrent = regKeyCurrentUser.OpenSubKey(@"AppEvents\Schemes\Apps\Explorer\Navigating\.Current", true);
            regSubKeyCurrent.SetValue("", "");
        }

        private void Page_Unloaded(object sender, RoutedEventArgs e)
        {
            var regSubKeyDefault = regKeyCurrentUser.OpenSubKey(@"AppEvents\Schemes\Apps\Explorer\Navigating\.Default");
            regSubKeyCurrent.SetValue("", regSubKeyDefault.GetValue("",""));
        }
    }
}
于 2013-06-30T21:15:04.863 回答