Windows Phone 82013. 5. 7. 16:58

솔루션 익스플로러에서 show all file 아이콘을 누른후 bin과 ob 의 debug폴더를 삭제후 다시 빌드 하면 해결된다.




참고 : http://michaelcrump.net/resolution-unable-to-activate-windows-store-app-the-activation-request-failed-with-error-e-fail

Posted by 동동(이재동)
Windows Phone 82013. 3. 15. 12:10

navigation 에서는 goback을 두번해야 할떄가 있다…

 

여러가지 방법이 있겠지만 효율적인 방법을 소개~

 

바로 stack 에 있는 엔트리를 remove해서 back 하는 방법이다.

 

public class NavigationHelper
    {
        public static PhoneApplicationFrame RootFrame
        {
            get
            {
                if (App.Current.RootVisual is PhoneApplicationFrame)
                {
                    return App.Current.RootVisual as PhoneApplicationFrame;
                }
 
                return null;
            }
        }
 
        public static void Navigate(string url)
        {
            if (GlobalStates.Instance.IsLogging)
                return;
 
            if (url.Contains("http://"))
            {
                var asy = Launcher.LaunchUriAsync(new Uri(url, UriKind.Absolute));
            }
            else
            {
                RootFrame.Tag = null;
                RootFrame.Navigate(new Uri(url, UriKind.RelativeOrAbsolute));
            }
        }
 
        public static void Navigate(string url, object parameter)
        {
            RootFrame.Tag = parameter;
            RootFrame.Navigate(new Uri(url, UriKind.RelativeOrAbsolute));
        }
 
        public static void GoBack()
        {
            if (RootFrame.CanGoBack != false)
            {
                try
                {
                    RootFrame.Dispatcher.BeginInvoke(() =>
                    {
                        RootFrame.GoBack();
                    });
                }
                catch
                { }
            }
            else
            {
                if (RootFrame.CanGoForward)
                {
                    RootFrame.Navigate(new Uri("/Views/HubPages/HubPage.xaml", UriKind.RelativeOrAbsolute));
                }
                System.Diagnostics.Debug.Assert(false);
            }
        }
 
        public static int BackEntryCount()
        {
            return RootFrame.BackStack.Count();
        }
 
        public static void RemoveBackEntryLatest()
        {
            if (RootFrame.CanGoBack != false)
            {
                RootFrame.RemoveBackEntry();
            }
        }
 
        public static void RemoveBackEntry(int removeCount)
        {
            for (int i = 0; i < removeCount; i++)
            {
                if (RootFrame.CanGoBack == false)
                {
                    goto finalizing;
                }
 
                RemoveBackEntryLatest();
            }
 
        finalizing:
 
            return;
        }
 
        public static void RemoveBackEntryAll()
        {
            RemoveBackEntry(RootFrame.BackStack.Count());
        }
 
        public static void DumpBackEntryAll()
        {
#if DEBUG
            int i = 0;
 
            foreach (JournalEntry entry in RootFrame.BackStack)
            {
                if (entry == null)
                {
                    continue;
                }
 
                LogHelper.Debug("BackStack: entry[{0}]={1}", i, entry.Source);
 
                i++;
            }
#endif
        }
 
        public static void GoHome()
        {
            RootFrame.Navigate(new Uri("/Views/HubPages/HubPage.xaml", UriKind.RelativeOrAbsolute));
 
            //if (RootFrame.CanGoBack)
            //{
            //    NavigatedEventHandler handler = null;
            //    handler = delegate
            //    {
            //        RootFrame.Navigated -= handler;
            //        GoHome();
            //    };
            //    RootFrame.Navigated += handler;
            //    RootFrame.GoBack();
            //}
            //else if (RootFrame.CurrentSource.OriginalString.Contains("/HubPage.xaml") == false)
            //{
            //    RootFrame.Navigate(new Uri("/Views/HubPages/HubPage.xaml", UriKind.RelativeOrAbsolute));
            //}
        }
 
        internal static void GoToLogin()
        {
            NavigationHelper.Navigate(PageUrls.Login);
        }
    }

 

이건 navigationHelper class이고

 

실제는

NavigationHelper.RemoveBackEntryLatest();
             NavigationHelper.GoBack();

 

이렇게 사용하면 된다.

Posted by 동동(이재동)
Windows Phone 82013. 3. 4. 13:41

 

List 에 1,2,3 이 있으면 3,2,1 로 불러오고 싶을떄

 

List의 Reserve() 메소드를 이용한다.

 

하지만 옵저버블 컬렉션에서는 안되지만 방법이 있을듯하다.

 

 

 

참고 : http://msdn.microsoft.com/ko-kr/library/b0axc2h2(v=vs.85).aspx

Posted by 동동(이재동)
Windows Phone 82012. 12. 10. 12:35

 

일단 저장부터 ㅋ

private async Task FileSave(MemoryStream stream)
     {
         IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
         IStorageFile storageFile = await applicationFolder.CreateFileAsync(Const.LocalPlaylistFileName, CreationCollisionOption.ReplaceExisting);
         using (Stream fileStream = await storageFile.OpenStreamForWriteAsync())
         {                
             stream.Seek(0, SeekOrigin.Begin);
             await stream.CopyToAsync(fileStream);
             await fileStream.FlushAsync();
             stream.Dispose();
         }

 

로드하는부분

public async Task LoadAlbums()
       {
         
           IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
 
           IStorageFile storageFile = await applicationFolder.GetFileAsync(Const.LocalPlaylistFileName);
 
           IRandomAccessStream accessStream = await storageFile.OpenReadAsync();
 
           using (Stream stream = accessStream.AsStreamForRead((int)accessStream.Size))
           {
               var o = _serializer.ReadObject(stream);
               LocalPlaylist = o as ObservableCollection<LocalMyAlbum>;
           }
       }

 

일단 윈7이랑 조금 달라졌다.

 

참조한곳이랑은 약간 다르게 구현~

 

참고한곳 : http://dotnetapp.com/blog/2012/08/02/windows-phone-8-shared-core-with-windows-8-file-io/

Posted by 동동(이재동)
Windows Phone 82012. 12. 6. 16:25

일단 내가 하고자 하는것은 멜론 플레이 리스트에 수정모드와 일반모드가 있다.

 

일반모드에서 ApplicationBar에 편집 버튼을 누르면 ApplicationBar에 편집을 위한 다른 버튼이 생기게 하는게 목표다(삭제라든지)

 

일단 behind에서 하면 아주 쉽지만 ViewModel에서 하는방법은 없을까?.. 모르겠다..

 

그래성 생각한 방법이 IsReorderEnabled 란 프로퍼티를 만들고

 

 

 

private bool _isReorderEnabled;
 
       public bool IsReorderEnabled
       {
           get
           {
               return _isReorderEnabled;
           }
           set
           {
               Set<bool>(ref _isReorderEnabled, value); 
           }
       }       

 

그냥 View Behind코드에서 변경되었을때 이벤트를 걸었다.

 

public partial class PlaylistDetailView : PhoneApplicationPage
    {
        public PlaylistDetailView()
        {
            InitializeComponent();
            this.Loaded += PlaylistDetailView_Loaded;
        }
 
        private void PlaylistDetailView_Loaded(object sender, RoutedEventArgs e)
        {         
            (DataContext as PlaylistDetailViewModel).PropertyChanged += PlaylistDetailView_PropertyChanged;
        }
 
        void PlaylistDetailView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "IsReorderEnabled")
            {
                if ((DataContext as PlaylistDetailViewModel).IsReorderEnabled == true)
                {
                    ApplicationBar = Application.Current.Resources["PlayListDetailEditAppBar"] as ApplicationBar;
                }
                else
                {
                    ApplicationBar = Application.Current.Resources["PlayListDetailAppBar"] as ApplicationBar;
                }
            }
        }
    }

 

머 이런방법도 있다 ㅋㅋ

Posted by 동동(이재동)
Windows Phone 82012. 10. 18. 11:18

원래 Generic 형식은 Global에서 사용이 되지 않았다.

 

하지만 .net framework 4.0 이상부터는 dynamic 을 지원한다. ㅋㅋ

 

윈폰7에서는 Compact net framework 라 안되었지만 windows 8 phone은 강력해졌다.

 

예를 들어 이렇게 Webclient 에서 Json Data를 받으면 알려주는 제네릭 Event Handler를 만들었다고 하자

 

public class CompleteEvent<T>
   {
       public event EventHandler<JsonDataEventArgs<T>> completeEvent;
 
       public void JsonDataEvent(T jsonData)
       {
           EventHandler<JsonDataEventArgs<T>> temp = completeEvent;
           if (temp != null)
           {
               temp(this, new JsonDataEventArgs<T>(jsonData));
           }
       }
   }
 
   public class JsonDataEventArgs<T> : EventArgs
   {
       T _jsonDataDict;
 
       public JsonDataEventArgs(T data)
       {
           _jsonDataDict = data;
       }
 
       public T XmlData
       {
           get
           {
               return _jsonDataDict;
           }
           set
           {
               _jsonDataDict = value;
           }
       }
   }

 

이제 이것을 전역변수로 정의 해보자

 

api.cs에

 

public CompleteEvent<dynamic> ce = new CompleteEvent<dynamic>();

 

이렇게 되면 이 클래스의 CompleteEvent를 어디서든 사용할 수가 있다 CompleteEvent<T>형식으로는 전역변수를 사용할수가 없다

Posted by 동동(이재동)