コード例 #1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            RewardModel vm = ((App)(Application.Current)).ViewModel as RewardModel;

            this.DataContext = vm;

            //Work around Silverlight Toolkit Bug for ToggleSwitch
            this.RoomForMediaSwitch.IsChecked = vm.MakeRoomforMedia;
        }
コード例 #2
0
        private void ApplicationBarOKIconButton_Click(object sender, EventArgs e)
        {
            RewardModel vm = ((App)(Application.Current)).ViewModel as RewardModel;

            //Work around Silverlight Toolkit Bug for ToggleSwitch
            vm.MakeRoomforMedia = this.RoomForMediaSwitch.IsChecked.HasValue ? (bool)this.RoomForMediaSwitch.IsChecked : false;

            ((App)(Application.Current)).SaveData();
            if (NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
            }
        }
コード例 #3
0
 public void LoadData()
 {
     // load the view model from isolated storage
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
         using (var stream = new IsolatedStorageFileStream("data.txt", FileMode.OpenOrCreate, FileAccess.Read, store))
             using (var reader = new StreamReader(stream))
             {
                 if (!reader.EndOfStream)
                 {
                     var serializer = new XmlSerializer(typeof(RewardModel));
                     ViewModel = (RewardModel)serializer.Deserialize(reader);
                 }
             }
 }
コード例 #4
0
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            LoadData();

            // if the view model is not loaded, create a new one
            if (ViewModel == null)
            {
                ViewModel = new RewardModel();
                ViewModel.Update();
            }

            // set the frame DataContext
            RootFrame.DataContext = ViewModel;
        }