Convert StorageFile to a BitmapImage in Universal Windows Apps

We have already seen how to convert a WritableBitmap to a StorageFile in Universal Windows apps. A StorageFile can be converted to a BitmapImage using the following function. public class ImageUtils { public static async Task<BitmapImage> StorageFileToBitmapImage(StorageFile savedStorageFile) { using (IRandomAccessStream fileStream = await savedStorageFile.OpenAsync(Windows.Storage.FileAccessMode.Read)) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.DecodePixelHeight = 100; bitmapImage.DecodePixelWidth […]

Read More

Convert Storage File to Byte Array in Universal Windows apps

This async function converts a storage file to a byte array. public static async Task<byte[]> GetBytesAsync(StorageFile file) { byte[] fileBytes = null; if (file == null) return null; using (var stream = await file.OpenReadAsync()) { fileBytes = new byte[stream.Size]; using (var reader = new DataReader(stream)) { await reader.LoadAsync((uint)stream.Size); reader.ReadBytes(fileBytes); } } return fileBytes; } It […]

Read More

Universal Windows App Project File Structure

All Universal Windows apps following MVVM pattern should have a similar directory structure. The following snapshot shows a possible project file structure of a Universal Windows app. Let us see briefly what all things go into each folders. App.xaml Controls: Reusable UI controls (application independent views) without view models. Platform specific Controls are added directly to […]

Read More

How to Check for Network Availability in Universal Windows apps

If you are building a universal Windows app or an app for Windows Phone 8.1/Windows 8.1 then the following class can help you check for network availability. Network Availability class This is a singleton class, which means only a single instance of it will exist during the lifecycle of the app. The method NetworkInformationOnNetworkStatusChanged gets […]

Read More

How to use Converters in Windows phone app (Silverlight/WinRT)

ValueConverters can be used whenever we need to present data in an easy and controllable way such that it doesn’t interfere with other layers of the application. Converters are called by the Data Binding mechanism whenever binding actually occurs (for example, when a control is notified about the change in the underlying property).   ValueConverters […]

Read More

Adding app review reminder in Windows phone app without using rate my app toolkit

Reviews are key to your app achieving success. High ratings in the Windows Phone Store encourage new users to download your app. So there’s no harm in reminding your users to review your app.   I have just prepared a following code which can be useful to you and doesn’t require any toolkit or third […]

Read More