Category Archives

Enabling / Disabling design data in Visual Studio 2015 Update 1

.NET, Blend, MVVM, Technical stuff, Universal Windows Platform UWP, Visual Studio, Work, XAML
No Comments

If like me you use design time data in Blend or the Visual Studio designer, you may have noticed a small change that is actually very convenient, but maybe not the most discoverable feature ever: You can now switch design time data on or off very easily!

To illustrate this, follow the steps:

  • Start Visual Studio 2015 Update 1.
  • (if you have not done so already) Install MVVM Light with: Tools / Extensions and Updates / Online –> Search for mvvm light and install the extension.
  • After restarting Visual Studio, select File / New Project and create a new MvvmLight (Win10Univ) application. This will create a new Windows 10 Universal project with all the MVVM Light scaffolding.
  • Open MainPage.xaml in the Visual Studio designer (or select Design in Blend from the context menu on MainPage.xaml).
  • Make sure that you set the configuration manager to x86 (not ARM or x64).
  • Build the application.

At this point, you will see one of two images below:


Figure 1: Design data is enabled


Figure 2: Design data is disabled

What’s the difference?

If you study both figures closely, you will see the difference at the bottom: Figure 1 shows actual data created in the code of the MVVM Light application (“Welcome to MVVM Light [design]” and the “Starting…” label for the Clock), while figure 2 shows the names of the databound properties (WelcomeTitle and Clock) instead. Switching from one figure to the other is done by using a new button on the design surface, which is a little hard to find. Here is an illustration:


This small button is tooltipped “Enable Project Code”.

What this button does is enable or disable a feature that MVVM Light applications are taking advantage of: The possibility to run some of your app code while the application is loaded in the visual designer. If the button is toggled on, the design time code will be enabled, which explains why the WelcomeTitle label shows the design time text, and the Clock shows the initialization text. This is useful, because it will allow you to design your app visually without having to actually run it, and so you will be faster.

On the other hand however, design time code can crash the visual designer. This type of errors can be fixed by updating the design time data, but they are time consuming, and sometimes it is just not worth it. In those cases, you may want to disable the design time code for the current view, which can be done by toggling the small button off.

In the case where the button is disabled, you can still edit the UI somehow, because the name of the property will be shown, and you can at least set the font, font size, foreground color  etc, which is better than nothing. For lists, this works too: If the design time code is enabled, the design time elements will be shown like in figure 3. On the other hand, if you disable the design time code, three “dummy” items will be created, which allows you to edit the item template visually. Here is an example taken from an app I am currently working on.


In addition, it also enables some level of design work with configurations that were not initially supported by the visual designer: ARM and x64. You can verify this by changing the configuration in the MVVM Light application above. Here the toggle button becomes disabled, and the view in figure 2 is displayed.

Having the possibility to disable design time code renders the visual designer more stable by allowing the user to eliminate possible design time error from the equation, and to still use the designer even if the design time code fails. It also allows some level of designer usage even with ARM or x64 configurations. This should accelerate things especially towards the end of the project, when maintaining the design time data can be time consuming.

Happy coding

GalaSoft Laurent Bugnion
Laurent Bugnion (GalaSoft)
Share on Facebook

MVVM Light V5.2 is live!

.NET, Blend, MVVM, Technical stuff, Universal Windows Platform UWP, Windows 10, Xamarin, XAML

This week I published MVVM Light V5.2 to Nuget and to the Visual Studio Gallery.

There are a few highlights which are described as always in the Change Log. See further below for a more detailed explanation of some of the changes.

Read the rest of this entry »

Using #mvvmlight with Windows 10 universal applications

.NET, Blend, MVVM, Phone, Technical stuff, Universal Windows Platform UWP, Windows 10, Windows Phone, XAML

Yesterday, Microsoft released to the public the development tools for Windows 10 (technical preview). With this release, you can start developing applications targeting the universal application platform (UAP).

Of course MVVM Light is present on this new platform too and allows you to build decoupled applications with the MVVM pattern. More than ever, XAML and the data binding system allow you to build applications in a fast and comfortable manner for a large number of devices with Windows 10.

Read the rest of this entry »

Announcing MVVM Light V5 for Windows and Xamarin

.NET, Blend, MVVM, Phone, Silverlight, Technical stuff, Visual Studio, Windows 8, Windows Phone, Work, WPF, Xamarin, XAML

Here at the Xamarin Evolve conference in Atlanta, I just announced the immediate availability of MVVM Light V5. This version runs on the following platforms:

  • Windows Presentation Foundation (3.5, 4, 4.5, 4.5.1)
  • Silverlight (4 and 5)
  • Windows Phone (7.1, 8, 8.1 Silverlight, 8.1 RT)
  • Windows Store (8, 8.1)
  • Xamarin Android
  • Xamarin iOS
  • Xamarin Forms

Read the rest of this entry »

Getting ready for Xamarin Evolve!

.NET, Blend, IdentityMine, MVVM, Phone, Technical stuff, Windows Phone, Work, Xamarin, XAML

This year, I decided to speak less at conferences, after last year’s mad rush. As much as I love to speak in public and share knowledge, last year was a bit too much and I ended up in December really tired. So this year, I didn’t submit much and I will only have had a few speaking engagements, including the excellent Techorama in Belgium in the beginning of the year.

This makes me even happier and more excited to take part to Xamarin Evolve this year. Honestly, I think the last time I was so excited about public speaking was at the memorable and amazing MIX conferences. I heard so many good things about Evolve, and I am really happy to be part of it this year.

Read the rest of this entry »

MVVM Light Fundamentals, a Pluralsight course

.NET, Blend, MVVM, Pluralsight, Silverlight, Technical stuff, Windows 8, Windows Phone, Work, WPF, XAML

Today, my Pluralsight course “MVVM Light Fundamentals” was published. It is the achievement of a long road for me, the conclusion of an adventure that started more than a year ago with the awesome people at Pluralsight. I won’t talk too much about why it took me so long to create this course, let’s just say that creating videos is really a totally different business than book writing. I had to work a lot to find the right way to do things, and especially find ways to optimize the act of recording the video, which I can only do when I am not travelling. It took a while until I found the correct way to do things. Everyone says that the first course is horribly hard, and I can vouch for that. They also say that the next courses are much easier, and I hope I can prove this too :)

Read the rest of this entry »

XAML Intellisense just got better

.NET, Blend, Build, Design, MVVM, Phone, Silverlight, Technical stuff, Visual Studio, Windows 8, Windows Phone, Work, WPF, XAML

With the latest Visual Studio Update 2 release candidate came a pretty wonderful surprise from the XAML tools team: Improved Intellisense when you use MVVM Light.

Short story

After you install the latest update to Visual Studio, you will notice the following effect:

Read the rest of this entry »

Building a Universal Application for Windows Phone 8.1 and Windows 8.1 with MVVM Light

.NET, Blend, Build, MVVM, Phone, Silverlight, Technical stuff, Windows 8, Windows Phone, Work

In the previous article, we talked about the new Universal apps which can be created for Windows Phone 8.1 and Windows 8.1. This offers a nice way to structure your app in order to share as much code and other files (artwork, etc) as possible. It makes it easier than ever to create apps which target both the Windows Phone and the Windows RT devices like Surface.

The new concepts can be a little confusing and overwhelming at first, but practice will help a lot. In this article, we will see how a new Universal app can be created with MVVM Light support. That should be fun!

Creating the app and adding MVVM Light support

Let’s start by creating a new universal application:

Read the rest of this entry »

Teaser: my MVVM Light reference course at Pluralsight is almost ready

.NET, Blend, MVVM, Phone, Pluralsight, Silverlight, Technical stuff, UX, Windows 8, Windows Phone, Work, WPF

Boy how long did I wait for that! The MVVM Light reference course at Pluralsight is almost ready! We just have a couple more modules to review, a little polish to be done, a few questions to be written and then we are done.

So here’s a small teaser series. To build up some anticipation, I decided to show you the title of the modules and sections. For this course, I assume a prior knowledge of XAML but no knowledge about MVVM is required.

Read the rest of this entry »

Using the EventArgsConverter in MVVM Light, and why is there no EventToCommand in the Windows 8.1 version?

.NET, Blend, MVVM, Silverlight, Technical stuff, Windows 8, Windows Phone, Work, WPF

If you installed the latest version of MVVM Light, you might have noticed that EventToCommand is still missing from the Windows 8.1 DLLs. Why is that?

Historically, Behaviors have been added only in Windows 8.1 (they are not available in Windows 8.0 at all). Some of us developed workarounds, such as the attached behavior I published in May with my MSDN article about commands.

During that time, I have been in constant touch with the Blend team and the Windows 8 team to talk about the possibility to have behaviors in Windows 8. Very fast it became apparent that this could only be done with a few changes to the underlying implementation of Windows, and thus that it would be a Win8.1 only story. I was lucky to get invited to an early SDR (software design review) of the new Windows 8.1 Behavior implementation and to give feedback. Notably, I noticed that the InvokeCommandAction behavior was still missing a way to get the EventArgs down to the ViewModel, and asked the team if they could add this.

Read the rest of this entry »