Design time support of example data

May 16, 2012 at 3:57 PM


it seems to me that the changes from Rev. 561 break the functionality of using example data in VS 2010 designer via a design time version of the view model..

After commenting these changes example data is shown in the designer as before.

May 16, 2012 at 4:48 PM

Interesting. This could be because of a fix I made to allow the binding wizard in VS2010 to work (I immediately call return in the ctor of ViewModelBase if in design mode). Do you have a repro which I can use to solve your issue?

May 16, 2012 at 6:58 PM

I just created a new Application with the project template "WPF Application with Catel" named "WPFAppliaction1"

I modified "MainWindow.xaml" as follows:

<catel:DataWindow x:Class="WPFApplication1.Views.MainWindow"
                  d:DataContext="{d:DesignInstance ViewModels:DesignMainWindowViewModel, IsDesignTimeCreatable=True}"
                  ShowInTaskbar="True" ResizeMode="CanResize" SizeToContent="Manual" WindowStartupLocation="Manual" WindowState="Maximized">

        <!-- Resources -->
    <!-- Content -->
     <catel:StackGrid x:Name="LayoutRoot">
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        <Label Content="{Binding Title}" />
        <Label Content="Here goes your real content" />

And I added a design time view model:

public class DesignMainWindowViewModel : MainWindowViewModel
        #region Variables

        #region Constructor & destructor
        /// <summary>
        /// Initializes a new instance of the <see cref="DesignMainWindowViewModel"/> class.
        /// </summary>
        public DesignMainWindowViewModel()
            : base()


The property "Title" of the View Model returns "View model title". This is already part of the base class "MainWindowViewModel as it has been created by the project wizzard.
Therefore the DesignMainWindowViewModel doesn't add additional sample data.
The label in the view which is bound to that property shows this string in the designer in case the modifications from Rev. 561 are commented out (no immediate return in the ctor of ViewModelBase in design mode)

After the changes of Rev.561 are applied the designer doesn't show that string anymore.

May 16, 2012 at 6:59 PM

Great, thanks for this info. I am currently writing some unit tests for the MessageMediator. As soon as I am done with that, I will take a look at this issue.

May 16, 2012 at 8:29 PM

Bindings are working again, and I didn't re-introduce the issue where the fix was needed for (actually, it only occurs when having models on a view model), so thanks for letting us know :)