我希望在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的新手)
答案 0 :(得分: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("",""));
}
}
}