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...

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: 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

Creating a Dialog service for Windows Store apps using Caliburn.Micro

Friday, November 28, 2014

When you want to display a dislog screen in windows store apps, you can use Flyout, MessageDialog or Popup the first two should be used for the simple cases – message prompts, question, basic user interaction. But if you need to display a richer dialog then Popup is the right fit. The MVVM way to open those dialogs is by using some kind of DialogService that will be called from you ViewModels. in all the sample i've seen on using Popup it always has a strong coupling to the View itself, meaning the Popup was embedded inside the view...
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...

Converting Event-based Asynchronous Pattern into Task-based Asynchronous Pattern in C++ using PPL

Tuesday, April 23, 2013

In C# we have many ways for writing asynchronous code, we can create our own thread (a bad practice most of the times), we can use the thread-pool, we can use BackgroundWorker or we can use Tasks (and Async\Await which is based on tasks) In order to notify the completion of an asynchronous operation we also have a few options (which depends on the type of dispatch mechanism we used). We can raise event when the work is done, we can call a callback function, or we can use a continuation style like Task.ContinueWith() or the Async\Await pattern...
no comments

Concurrency, WinRT ObservableCollection and Iteration

Monday, January 14, 2013

You can download the source-code from Today I want to discuss a problem I faced in a WinRT project I'm working on The short story: We receive events from the network on a background thread(s) The events bubble up to the UI layer and caught in the ViewModel The ViewModel changes an inner ObservableCollection in response to the event One thread is adding\removing from the collection while another searches for an element in it. The search is iterating a collection that is being modified è Exception is thrown  The solution to the problem is one of two: Making a lock mechanisem on the collection...

Adding Localization support to WinRT C# Application

Wednesday, January 2, 2013

When we create applications we usually want to make them easy to use by our users. One way to make application more accessible internationally is to make it localized to the users' language and regional settings. In this post I wish to show how to add localization support to your WinRT C# application. All the source code can be downloaded from my GitHub: Sample App I created a simple application that includes a simple login page (the app includes only UI) and currently supports "en-US" and "he-IL" locales   English version Hebrew version  How does it work? Create a new Windows Store project –...

How to get a unique Device ID in WinRT (C#)

Tuesday, December 11, 2012

In a project I'm working on I needed to get an ID that uniquely identifies the device that is running the app. WinRT provides an API for HardwareIdentification but you should be aware that the call to GetPackageSpecificToken method will produce different value for each app that calls it.And if you have several applications that needs to interact with a websevice and pass the device id you can't rely on it for identification.Another approach you can use is taking the NetworkAdapterId , which is like using the MAC address (WinRT doesn't give an API to take the MAC itself).Here is a...