Sep 22, 2013

Handy Boolean value converters


WPF, Silverlight, and Windows Store apps often use value converters to massage data into the proper format for data binding. Although WPF provides a built-in BooleanToVisibilityConverter class, the Silverlight and Windows Store frameworks do not, and it’s convenient to have several other frequently-used converters lying around. In this post, we focus on a few simple conversions between Boolean values and other types, all of which can be derived from a single generic base class:

read more
Jul 07, 2013

A better BindableBase

Visual Studio has some great features built into its project templates for Windows Store applications. In particular, the Grid App (XAML) and Split App (XAML) project templates include the BindableBase class, which serves as a convenient starting point when building view models for data binding. The BindableBase class provides an implementation of INotifyPropertyChanged, along with a convenient SetProperty method that makes it easy to add properties to your view model. Getting property change notifications to work correctly with data binding is as simple as adding a field and…

read more
Apr 03, 2013

How to debug pointer capture


In our previous blog post, we mentioned some of the challenges developers face in creating keyboard-friendly applications, and we presented our FocusWatcher class for debugging these issues in Windows Store apps. The keyboard is just one way an app may receive input; Windows Store apps can also get input from mouse, stylus, and of course, touch. Modern tablets and touch screens often support multiple simultaneous touch inputs, in fact. All these different inputs can make it tough for developers to figure out what’s going on, especially when combining…

read more
Feb 11, 2013

How to debug keyboard focus


When it comes to interacting with a graphical user interface, touch and mouse input typically come to mind first, and get the lion’s share of a developer’s attention. However, there are plenty of users who prefer to type or must type, and therefore it’s important to make sure applications work well with the keyboard. Fixing keyboard focus issues is the first step, whether you are making your application accessible to blind users or making it easier for everyone to navigate. Here are some problems we frequently encounter when…

read more
Jan 05, 2013

How to simultaneously enable/disable multiple controls


In a comment after our last blog post, a reader named Craig asked an interesting question. He wanted to know how he could enable and disable controls according to their individual needs, but also disable groups of controls simultaneously when his application is busy working on a long-running task. For example, in the text editor of a programming environment, the cut and paste buttons should be enabled or disabled depending on the current text selection and clipboard contents; however, while the programming environment is compiling code, all of…

read more
Dec 09, 2012

How to position data bound items

A long time ago in a galaxy far, far away, we wrote about the power of styles and templates in WPF, showing how ordinary-looking list box items could be transformed into a visualization of the planets in our solar system. Recently, we noticed that some of the techniques described there don’t work in Windows Store applications for Windows 8. In this post, we’ll revive the planets list box and describe the changes required to make it to work in a Win8 app. As in the WPF version, the…

read more
Nov 06, 2012

Binding RadioButtons to an Enum – Part V


Our last few blog posts presented four different solutions to bind a list of RadioButtons to an enumeration. Today we will discuss some of the pros and cons of each of these solutions. Hopefully this analysis will help you decide which solution is right for your scenario. Solution 1 – Use a ListBox to track selection and style its ListBoxItems to look like RadioButtons It’s a bit of work to re-style a ListBox and its ListBoxItems to look just right, and the resulting styles are quite verbose. However,…

read more
Oct 29, 2012

Binding RadioButtons to an Enum – Part IV


This is the fourth of a series of posts covering different options to bind a set of RadioButtons to an enumeration. The sample code provided here is written using WinRT for Windows Store applications running on Windows 8. Today’s solution binds each RadioButton’s IsChecked property to a helper class. This helper is a reusable generic class that wraps an enumeration and adds two-way binding capabilities. Our model is still the same: …

read more