Windows Phone 72012. 4. 5. 17:51

계속 SelectIndex가 바꼈는데도 SelectChanged이벤트를 일으키지 않아서

ViewModel에서 이렇게 바로 View로 접근해서 수정하였다.

 

Deployment.Current.Dispatcher.BeginInvoke(delegate
                {
                    ((Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as GloryApp.Views.CheckInListView).xTicketList.SelectedIndex = -1;
                    ((Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as GloryApp.Views.CheckInListView).xTicketList.SelectedIndex = 0;
                });
Posted by 동동(이재동)
Windows Phone 72012. 1. 3. 21:16

회사에서 ViewModelBase(회사에서 쓰는 ViewModel dll)을 이용한다.

하지만 이건 ViewModel만들때 상속해서 써야 한다.

하지만 UserControl을 만들어 버리면 이미 UserControl을 상속받았기 때문에 ViewModelBase를 다중상속받아야 한다.

하지만 Property Binding이 목적이라면 이렇게도 쓸 수 있다.

 

#region CurrentCount

      private double _currentCount;

      /// <summary>
      ///
      /// </summary>
      public double CurrentCount
      {
          get
          {
              return _currentCount;
          }
          set
          {
              _currentCount = value;
              
              OnPropertyChanged("CurrentCount");
          }
      }

      #endregion CurrentCount

      #region Event

      /// <summary>
      /// PropertyChanged 이벤트 핸들러.
      /// </summary>
      public event PropertyChangedEventHandler PropertyChanged;

      /// <summary>
      /// OnPropertyChanged()
      /// </summary>
      /// <param name="propertyName"></param>
      protected void OnPropertyChanged(string propertyName)
      {
          if (PropertyChanged == null)
              return;
          PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }

      #endregion Event

이렇게 이벤드 핸들러를 만들어서 OnPropertyChanged를 구현한다.

Posted by 동동(이재동)
Windows Phone 72011. 3. 31. 17:54

이란 에러 메세지를 자주 본다.

 

만약 behind코드(xaml.cs)라면

 

Dispatcher.BeginInvoke(() =>
                                    {
                                        NavigationService.Navigate(new Uri("/Views/RecordView.xaml", UriKind.RelativeOrAbsolute));
                                    });

 

이렇게 쓰면 되겠지만

 

ViewModel 이나 Service에서는 어떻할까?

 

Deployment.Current.Dispatcher.BeginInvoke( ()=>
                       {
                           ServiceLocator.Current.LocationPermissionViewModel.NoButtonClick(null);
                       });

 

이렇게 쓰면 된다.

 

참조 : http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/43177228-1ab2-4489-afea-89b0bf61bdd7

Posted by 동동(이재동)