Design time support of example data

May 16, 2012 at 3:57 PM

Hello

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.

Coordinator
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"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:catel="http://catel.codeplex.com"
                  xmlns:ViewModels="clr-namespace:WPFApplication1.ViewModels"
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                  mc:Ignorable="d"
                  d:DataContext="{d:DesignInstance ViewModels:DesignMainWindowViewModel, IsDesignTimeCreatable=True}"
                  ShowInTaskbar="True" ResizeMode="CanResize" SizeToContent="Manual" WindowStartupLocation="Manual" WindowState="Maximized">


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



And I added a design time view model:

public class DesignMainWindowViewModel : MainWindowViewModel
        {
        #region Variables
        #endregion

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

 

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.

Coordinator
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.

Coordinator
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 :)