2013-06-30 411 views
0

我想完成一些像他們在Modern UI for WPF。我有主窗口:NavigationWindow,其來源是頁/main.xaml和我的代碼中,它看起來是這樣的:C#WPF頁面切換

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

你也許找一個TabControl? http://tech.pro/tutorial/730/the-wpf-tab-control-inside-and-out – Lucas

+0

不,我只想擁有按鈕並點擊更改窗口內容。在WPF的現代用戶界面中,他們正在用完成我想要的功能。我只想用按鈕來做同樣的事情。看看http://mui.codeplex.com/wikipage?title=My%20first%20Modern%20UI%20app&referringTitle=Documentation –

回答

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("","")); 
     } 
    } 
}