After a weekend break, which was not a real break since I continued to work on filtering issues for half a day on Saturday, it is now the day to complete the two remaining filter bugs. I wish I could have been done with these issues but this is such an important part of the app that I want to make sure it is all working perfectly. The last two problems as visual and relate to the location of the tick marks and labels on the Telerik RangeSliders customized for the Windows Store app. After continued struggles this weekend, I am beginning to think that maybe I am trying to force the control to do something it was no intended to do. From my experience I have done this same thing with other controls in the past so I know the request is not totally unusual. I may just have to get the tick marks and labels close enough as the working filters are the most important part and that is all working as it should be. I am going to leave that alone for today and move on.
So the big task for day is working with Windows Store app settings. So the first place to start is the generic Windows Store guidelines of Settings. Once that was read then I found probably the best quick start guide so far on how to use the new Windows 8.1 Settings service. I had to look up the ToogleSwitch class as I had not used that before and it is highly customizable. I had to look up how to set the default switch value as the IsOn property was a bit odd for me as I just assumed it I needed a slight refresher on how to define get/set accessors since the break away from C# must have caused some memory loss. I also needed to look up the best way to compare strings as well. This is kind of getting depressing that I did not remember those two things. The hardest part was figuring out how to know when the Settings flyout was closed. There is a BackClick which was easy to handle in the SettingsFlyout class.
Then in testing I found out that you can use Escape key while the Settings is up so I need to handle that case. I searched for a solution and found a sample app that did just this which really proved helpful as that just was not obvious at all. In a way it makes sense that to know when the Escape key was pressed that a global listener was needed but defining it on "Window.Current.CoreWindow" was not my first guess, second guess or ay guess for that matter. The sample app should how to have multiple pages of settings that depend on each other, which I did not need, but learning how to handle key events was a new lesson. It also required learning about Virtual Keys to check for the specific Escape key in the handler.
I then found an odd issue when the Escape was used on the keyboard and the Settings flyout went away I had a nice white outline around by AppBarToggleButton. Naturally I tried the obvious thing to do, which was remove the focus. My intuition let me down as that immediately caused an exception and when I looked up the Focus State documentation that was in the first line that doing so would cause an exception. As a work around I set focus to the main window and that fixed my problem from a keyboard stand point.
The next issue to figure out is how to know when my toggle switches have been changed in the Settings flyout. It is time again to use Data Bindings so I go back to that quick start guide. This requires a single INotifyPropertyChange interface by adding a PropertyChangedEventHandler and a very simple PropertyChangedEventArgs with the name of the property that was changed. That was not a big deal as I had dealt with those before.
The last problem was figuring out how to save my Settings once I had the flyout working correctly. That took a bit of searching but yet another great quick start article helped me understand how to solve that problem by using Windows.Storage.ApplicationData.Current.LocalSettings. After a short break in Windows Store app coding, it makes the documentation seem even better as I have had two new things I needed to do and I found the documentation to solve both quickly.
I am pretty happy that it only took me one short day to add custom preferences for my Windows Store app.
No comments:
Post a Comment