Dealing with page resize in Windows Store Applications using Caliburn.Micro

Sunday, March 1, 2015

Windows Store Applications allow the user to change the size of the application and change the the layout to e vertical or horizontal. in order to provide god user experience we want adapt our view to different modes. For instance, showing a grid like view when in Full Horizontal mode and change it a List when we are snapped to side (and look vertical). The examples and guidelines on how to change your view based on the page layout change are around those option: In your page XAML write the representation for both mode and change visibility...

StringSplitterConverter–binding to a part of a string in XAML

Sunday, December 21, 2014

I’m involved in a Windows Store project that needs to deal with localization. I already write a about localization in Windows Store application in January 2013 so you are welcome to read about it. Our Xaml designers came to me the other day with an issue they found irritating. They needed to show some text on the screen that contain both regular text (some as bold, some italic etc.) and hyperlinks and if that’s not enough the text-resource was localized. One way to solve this is to separate the text-resource to multiple parts and store each one independently...
no comments

Getting the Free Storage Space in WinRT

Tuesday, December 16, 2014

I didnt find any documenation to this method other than the thread in StackOverflow: http://stackoverflow.com/questions/19510449/disk-space-in-winrt-using-c-sharp-in-windows-8 so im keeping it here so it wont get lost by the winds of time…. public static async Task<UInt64> GetFreeSpace(this IStorageItem sf) { var properties = await sf.GetBasicPropertiesAsync(); var filteredProperties = await properties.RetrievePropertiesAsync(new { "System.FreeSpace" }); var freeSpace = filteredProperties; return (UInt64)freeSpace; } Sample use: var freeSpace = await ApplicationData.Current.LocalFolder.GetFreeSpace(); Debug.WriteLine(freeSpace.GetSizeString()); Thank you  Filip Skakun
no comments

InvalidOperationException When Working With IAsyncOperation<TResult>

Thursday, November 27, 2014

WinRT introduced the concept of IAsyncOperation for working with Asynchrounous code. the IAsyncOperation is merely a representation of an Async Operation (a future in the computer science lingo) and as the same meaning as hte .NET System.Threading.Tasks.Task class, so its not suprising to see that you can convert IAsyncOpertion<TResult> to Task<TResult> IAsyncOperation<int> asyncOperation=...; Task<int> task = operation.AsTask(); .NET Tasks has the Result property which gets the value of the async oprtation if it finished or wait till the value is available – this of course can cause the calling thread to freeze until the value is returned. IAsyncOperation has something...

System.Reflection.AmbiguousMatchException from xaml in Windows Phone

Wednesday, September 3, 2014

Lately I ran into a tricky bug inside a Windows Phone application. Sometimes an unhandled exception was thrown that caused the application to crash. Looking into the logs showed that the exception was System.Reflection.AmbiguousMatchException which is caused when the reflection mechanism finds more than one option for a member in a class. TL;DR; – Don't bind in xaml to a property with new modifer  The reason for the exception was that one of the team members decided to derive a class from some entity - lets call the entity Person. public class Person { public int Age...

Dealing with reentrancy with DelegateCommand

Monday, May 19, 2014

many times in our application we have some button (or another command invoker) that is executing a long processing operation. today, with the power of Async Await its even easier to run these long operations while keeping the UI responsive. usually we will use some kind of DelegateCommand to bind our button to the ViewModels’ operation MissleLauncherView.xaml <Button  Command="{Binding LaunchMissiles, Mode=OneTime}"/>   MissleLauncherViewModel.cs private ICommand _launchMissilesCommand;public ICommand LaunchMissilesCommand {    get    {        return _ launchMissilesCommand ?? (_launchMissilesCommand = new DelegateCommand(           async (_) =>            {                await LaunchLongMissileAttack();            }));    } } this impose a very serious problem, while the LaunchLongMissileAttack method is working, nothing is preventing the command from being called again…and again…and again in...
no comments

Rapidly changing source and the power of RX

Tuesday, May 13, 2014

Recently i needed to work with MediaElement on WP8 where the source URI for the MediaElement was something that was recieved from a 3rd party library using an event event EventHandler<VideoEventArgs> OnVideoChanged; Where VideoEventArgs is defined as follows: public class VideoEventArgs:EventArgs { Uri VideoStreamUri { get; set; } double Rotation { get; set; } //other properties Without going into too much details about the 3rd party, the URI it provides us is the source of the video that is currently broadcasting and rotation in which it was sent to us (think of a mobile device...
no comments

How to solve CannotOpen exception when using SQLite after publishing WP8 application to the Store

Wednesday, January 8, 2014

Recently I experienced a weird behavior in a Windows Phone 8 application I'm working on. In the application, we are using SQLite for our local DB. Everything worked great in the emulator and when deployed to a device. BUT When we uploaded the app to the store for Beta testing we got an exception on the first operation we made to the DB. After looking at the logs (which isn't that easy after an app is installed by the store), we found that the exception message was “CannotOpen”. After searching this type of error we...
no comments