void button_Click(object sender, RoutedEventArgs e) { try { #if ARM string str = string.Empty; if (Registry.NativeRegistry.ReadString(Registry.RegistryHive.HKLM, string.Concat("SOFTWARE\\Microsoft\\EventSounds\\Sounds\\", ((Button)sender).Tag), "Sound", out str)) #else string str = EmulatorData.NotificationEventValues[((Button)sender).Tag as string]; #endif { var ringtoneChooser = new RingtoneChooser() { SelectedRingtone = str }; var msgBox = new CustomMessageBox() { Tag = ((Button)sender).Tag, Caption = string.Format("choose sound notification\nfor event \"{0}\"", ((Button)sender).Tag), Content = ringtoneChooser, LeftButtonContent = "choose", RightButtonContent = "cancel", IsFullScreen = true, }; // Set background only for custom theme (not for default) if ((Application.Current.Resources["PageHeaderBackgroundBrush"] as SolidColorBrush) != (Application.Current.Resources["PhoneBackgroundColor"] as SolidColorBrush)) { msgBox.Background = Application.Current.Resources["PageHeaderBackgroundBrush"] as SolidColorBrush; } msgBox.Dismissed += (object boxSender, DismissedEventArgs ea) => { if (ea.Result == 0) { var tag = ((CustomMessageBox)boxSender).Tag as string; var value = ((RingtoneChooser)((CustomMessageBox)boxSender).Content).SelectedRingtone; var regEntry = new RegistryEntry(@"HKLM\SOFTWARE\Microsoft\EventSounds\Sounds\"+tag, "Sound", RegDataType.REG_SZ); regEntry.Value = value.Equals("none") ? string.Empty : value; } }; msgBox.Show(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }