TAG: WinRT

Composite primary keys in SQLite.Net

SQLite.Net-PCL is one of the best SQLite client/ORM out there in a PCL form supporting Windows Store and Universal apps. It's open source, but it's not feature complete, and you may learn the hard way that some things are missing. Being open source is a good thing, which means that you can add support for anything you can imagine or need yourself. One of the things missing (currently, in the master branch of the…

Output SQLite queries when using SQLite-net in Universal apps

When debugging code which works with databases, you'll often want to see the queries which are being executed to find possible bugs or simply understand how the database wrapper works. There's a simple way to do it if you use SQLite-net wrapper, but as it's not documented, you have to guess or read the source code to find it. Going through source code is usually not a big deal (open source ❤), but I hope this will…

Pass ListView SelectedItems to ViewModel in Universal apps

One of the things that WinRT devs need to work around in Universal apps is the fact that you can't bind straight to SelectedItems of a ListView/GridView. There are a few ways to pass SelectedItems to the ViewModel and here's one that can get the job done quickly. The method I'll use in this post uses EventTriggerBehavior to invoke a command in ViewModel when a SelectionChanged event occurs. For that to work, you need to…

MenuFlyout flip animation on Windows Phone WinRT

MenuFlyouts are a standard part of Windows Phone apps. If you go to system apps such as Calendar and try to switch view by clicking the button in the Command/AppBar, you'll notice that the MenuFlyout shows and sort of flips. However, if you try to show a MenuFlyout in your app, you'll see that it has a different entrance animation. The system animation looks like this: Imagine you wanted to show a MenuFlyout when CommandBar…

Cancel page navigation in MVVM Light and WinRT

There are often situations in which you may want to cancel navigation. Imagine a form being filled in, and all of a sudden user accidentaly presses back button and ... whooops ... all entered data is gone. In that particular situation you might want to ask the user if he wanted to do that and if he wanted to preserve the data already entered. This article shows how to do it "MVVM-way" using MVVM Light. When it comes…

Larger ProgressBar rectangles on Windows Phone

Normally you'd want to use a standard size of rectangles in an indeterminate ProgressBar. However, in case that you need larger rectangles, there's an easy way to accomplish that! A standard way of adding a ProgressBar is just to define it in XAML and say that it's indeterminate by setting the IsIndeterminate property. In MVVM architecture you'd probably bind Visibility property to a property in your ViewModel (probably a boolean, then convert it with a converter…

Set supported orientations in XAML on Windows Phone 8.1

Being able to set supported orientations in XAML on every page by simply setting the SupportedOrientations property on PhoneApplicationPage is something Windows Phone developers are used to on Silverlight platform. However, with Windows Phone 8.1 and WinRT platform, it's possible to do so (only?) in code behind. On Windows Phone 8.1 you can set the supported orientations in Package.appxmanifest. Setting it that way means you're setting it on application level - all pages…

Get device information on Windows Phone 8.1 WinRT

I see many interesting question on StackOverflow every day. One of those today was the question about determining if Windows Phone 8.1 app is running in the emulator. Here's one way you can get that information! Finding out information about the device is useful in many ways, but one reason you might want that is definitely to know the difference between running on emulator and on a real device. Typical way of doing this on…

Measuring startup performance when using .NET Native Developer Preview

I got really excited about .NET Native technology last week when I first heard about it during Build. I wanted to measure performance in my Windows Store apps to see how it can improve it (especially startup times!), and in order to do that I was going to user EventSource and PerfView. Unfortunately, something didn't work, but the team helped me go around it! .NET Native is a new (cloud) compiler technology from Microsoft which, in…

MetroGridHelper performance with Windows 8.1

MetroGridHelper is a small helper class for XAML WinRT apps developed by Mark Monster which helps build perfectly aligned apps. As far as I remember, the idea for a metro grid helper goes back to early Windows Phone 7 development and a version for Windows Phone by Jeff Wilcox (Mark also credits him in his blog post). I've been noticing performance issues with it in Windows 8.1 apps during loading. Basically, splashscreen stays on much…

Scrolling GridView by placing mouse on edge

The start screen on Windows 8 has an interesting feature - it scrolls if you move your mouse to left or right edge, without the need for scrolling using the mouse wheel. I pretty much never use it because the scrolling is rather slow, and I usually know where I want to go so I can scroll faster, but for reading and exploring purposes, slower scrolling can come in handy. How to accomplish it using the…

Character ellipsis trimming in Windows Store apps

As a relatively new platform, WinRT is missing some of the features that WPF and even Silverlight developers are used to. One of those features is definitely the character ellipsis trimming feature for TextBlocks. I did a little research on that matter for one of my recent projects, and here’s what I’ve come up with. There are two types of trimming. One is called word ellipsis, in which the string is trimmed by cutting…

Advanced data caching in Windows Store apps

In this post we’ll be working with data caching in Windows Store apps using Q42.WinRT library and Flickr API, continuing from the last post “Data caching in Windows 8 apps”. Using the library, it’s very simple to do a lot more than just storing the data to local storage. The class we’ll be using today is called DataLoader, and it can be found in Q42.WinRT.Data namespace. It has three important…

Data caching in Windows 8 apps

When working with a lot of data in apps based on web services (JSON return format being quite common), you’d normally want to cache it in order to make your apps faster and make your users spend less Internet traffic on refreshing which actually isn't necessary. Also, if the users opens your app while having no Internet connectivity, it’s nice to show him something, even though it’s cached data. It’s always possible…

How to set vertical title in Windows 8 GridView items

One of the issues when it comes to space and properly designing a GridView on devices with 768 pixels of height is the fact that the title of each GridView item can often take just the amount of space on the top that you need to fit all your data. Considering the fact that the GridView is predefined to scroll horizontally and that in landscape orientation you get more space horizontally, why not put the title…

Microsoft Certified Solutions Developer: Windows Store Apps in C#