0
votes

I'm trying to learn Catel MVVM by getting the simplest of bare bones example of Catel to work on VS Express 2012 and keep getting an error. I think my problem lies in my "using" statements, references, or the header in my XAML. An auto-generated file writes the offending line as shown below in MainWindow.g.cs The code files are very short, so I've included them.

The model, viewmodel, and view are separated into three projects all under one solution.

  • Model- blank for now
  • ViewModel -MainWindowViewModel (no properties yet)
  • View -MainWindow.xmal, MainWindow.xmal.cs (no controls or properties yet)

    I keep getting the following warning with an accompanying error:

    The type 'Catel.Windows.DataWindow' in 'c:...\MainWindow.g.cs' conflicts with the imported type 'Catel.Windows.DataWindow' in 'c:...\Catel.MVVM.dll'. Using the type defined in 'c:...\MainWindow.g.cs'.

    and the error:

    Catel.Windows.DataWindow < ViewModels.MainWindowViewModel > is obsolete: 'Please use 'Catel.Windows.DataWindow' instead. Will be removed in version '4.0'.' C:...\MyFirstCatel\obj\Debug\MainWindow.g.cs

    MainWindow.xaml

    <Windows:DataWindow 
            x:Class="Catel.Windows.DataWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"           
            xmlns:MainWindowViewModel="clr-namespace:ViewModels"
            xmlns:Windows="clr-namespace:Catel.Windows;assembly=Catel.MVVM"
           x:TypeArguments="MainWindowViewModel:MainWindowViewModel"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <TextBlock>Hello world!</TextBlock>
        </Grid>
    </Windows:DataWindow>
    

    MainWindow.xaml.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Catel.Windows;
    
    
    namespace MyFirstCatel
    {
    
        public partial class MainWindow : Catel.Windows.DataWindow
        {
            public MainWindow() 
            {
                InitializeComponent();
            }
        }
    }
    

    MainWindowViewModel.cs

    using System.Windows;
    using Catel.MVVM;
    
    namespace ViewModels
    {
        public class MainWindowViewModel : ViewModelBase
        {
            public MainWindowViewModel()
                : base()
            {
            }
    
            public override string Title { get { return "View model title"; } }
    
            public string Slug
            {
                get { return GetValue<string>(SlugProperty); }
                set { SetValue(SlugProperty, value); }
            }
    
            public static readonly Catel.Data.PropertyData SlugProperty = RegisterProperty("Slug", typeof(string), null);
    
        }
    }
    

    And in MainWindow.g.cs

    namespace Catel.Windows {
        public partial class DataWindow : Catel.Windows.DataWindow<ViewModels.MainWindowViewModel>, System.Windows.Markup.IComponentConnector 
    {
         private bool _contentLoaded;
         ... code removed for post ....
    
    }
    

    }

  • 1

    1 Answers

    0
    votes

    There is only one thing that is wrong. Inside your xaml definition you still use the old way of specifying the vm type. Remove the x:TypeArguments and the error should go away.