Watermark TextBox in Windows Store apps

A common request for WSAs is to add a "watermark" to TextBox entries so users get a hint as to what is expected in the TextBox. You can see this in many Search Charm implementations as it allows a search hint to be provided via the SearchPane.PlaceHolderText property.  However, the built-in TextBox in XAML doesn't have this feature (HTML does!). There are a few custom controls out there which allow for this, however, I'm a big fan of behaviors over custom controls - so when I needed this, I … [Read more...]

Variable sized tiles in Windows Store Apps

One of the common requests I hear when training customers on Windows 8 is "How do I create variable sized tiles in a GridView?" The Windows Store app utilize this technique where different tiles have different sizes to promote content. It turns out this is relatively easy in HTML - which is probably one of the reasons Microsoft chose to use that visual platform to build the app.  In XAML however, this is a bit more difficult.  There are many posts which detail using a VariableSizeWrapGrid … [Read more...]

Synchronizing Collections in Windows Store Apps

One issue that often comes up when building WSAs is managing selection in your filled/snapped/full screen views.  The goal, of course, is to provide a reasonable view as the user snaps your application which is often done by providing two UIs within the page - one with a GridView for filled or full screen and the second with a ListView for snapped view.  You hide and show the two views using the Visual State Manager when using the normal templates. If selection is provided, then ideally it … [Read more...]

Navigation and Persistence with MVVM in Windows Store Apps take #2

Earlier I posted on an updated version of MVVMHelpers with persistence support (see here). Paulo Quicoli, a long-time MVVMHelpers contributor, sent me a little code and a different way of managing navigation and persistence that he's been using. I thought it was quite elegant and asked if I could include a version in the library, which he graciously agreed to.  The result will be in the next release of the library - but I thought I'd introduce it here. The idea is to use a serializer on the … [Read more...]

MVVMHelpers.Metro updated

The Metro version of MVVMHelpers was updated yesterday with some key new features, one of them is some built-in state management for process lifetime and navigation. This is done through two interfaces - IPageNavigator and IStateManager. You can use them independently, or together. By default, if you don't assign one, the PageNavigator service will internally create a StateManager to store off page navigation state. You can supply your own IStateManager implementation by either overriding the … [Read more...]

Using behaviors with ElementName bindings in Windows 8 Metro

I got an email yesterday from a developer who was trying to use MVVMHelpers and the new System.Windows.Interactivity support for Windows 8 and was having trouble. Specifically, he was trying to do this: The idea was to have a command get invoked when an item is tapped in the ListView - passing the selected item as the parameter to the command. He was always getting null in his command handler. There are actually two issues with this snippet, one is in the setup of the ListView itself and the … [Read more...]

Problem with MEF in Windows 8 style apps (Metro)

I noticed when I use NuGet to add MVVMHelpers, the app refuses to start.  I get the following error: "Unable to activate Windows Store app xxx, The activation request failed with error 'The app didn't start'." Wow.  Totally unhelpful - even chasing down the event logs didn't really help much other than to show me a lot of weird errors get logged from Metro apps about tiles! After experimenting a bit, it turns out the fix is quite simple.  MVVMHelpers relies on MEF for composition and … [Read more...]

MVVMHelpers for Windows 8 Metro RTM released

I have updated the MVVM Helpers for Metro to the RTM Windows 8 build.  If you've been following the source changes, you might notice I've included full support for Blend Behaviors - even though Blend itself doesn't support them!  To accomplish this, I ported the System.Windows.Interactivity.dll to Metro and include it as part of the package - I'll remove this once Blend supports behaviors officially. I've also ported the most useful of the Blend behaviors and behaviors from the WPF MVVMHelpers. … [Read more...]

MVVMHelpers for Windows 8 Metro

I've been doing some Windows 8 Metro programming lately and to help with building more testable applications have ported the MVVMHelpers (mvvmhelpers.codeplex.com) over to Metro/.NET 4.5.  This post is intended to introduce the functionality and show it off a little. First, we'll create a new Metro-based Blank application using Visual Studio 2012: Next, let's add references to the MVVM library - we'll use NuGet, but you can also downloads the source or binaries from Codeplex.  Make sure you … [Read more...]

Dynamic type binding in WPF 4.5

One of the new features in WPF 4.5 is data-binding support for ICustomTypeProvider. This enables adding dynamic properties to types where the actual shape of the type is not known until runtime. For example, where the data itself is being retrieved from a web service (JSON) or from an XML definition. This feature was also added in Silverlight 5 so we have feature parity here (almost). ICustomTypeProvider allows you to define the bindable properties at runtime with full type knowledge … [Read more...]