0
votes

I was evaluating to migrate a quite new project from Caliburn Micro to Catel.. I want to share with you my thought and get a feedback from you

Let's start with my app structure:

  • WPF application based on MVVM
  • Telerik Usercontrol Suite
  • Use of ServiceStack to retrieve data from a webserver
  • Use of SimpleInjector for IoC
  • NLog for logging
  • TCP/IP Connection to remote server
  • FW 4.0 with Microsoft.BCL.Async
  • The application is similar to Visual Studio (Docking)

Now that almost is clear the structure I'll start with my questions:

  1. My models are filled via ServiceStack.OrmLite so they're POCO with property and not dependency property-like , since the models are shared on the webserver and WPF part I don't want to inherit from ModelBase, should I have to re-create the object what inherits from modelbase when data arrives on the WPF part?
  2. The data shown in the RadGridView are bound to a Model Property,as far as I've seen here , I've to pass to the ViewModel the Model how can I bind those data to the Grid or view in general?
  3. I find quite usefull in CM the Convention so if I name a TextBox x:Name="Surname" it looks for a property Surname, in Catel should I do ? or does something similar exist?
  4. In my application I make large use of async can do this with Catel?
  5. I've read that I can substitute the Catel's default Ioc provider with SimpleInjector ... anyone has got succed with it?

Thanks

UPDATE #1

Explanation about models

Consider an object of type Person for simplicity which will be loaded from webservice via Servicestack

[Alias("Person")]
public class Person 
{
[Alias("NAME")]
 public string Name {get;set;}

[Alias("SURNAME")]
public string Surname {get;set;}

}

This will be returned as a IList and maybe loaded in a GridView

Now the user wants to edit it so I'll load this Person into another viewmodel called UpdatePersonViewModel (shown in a popup)

If I have not implemented it as you've done in your sample I won't be able to use Catel Validation and so on right? so maybe I've to create a PersonModel that takes a Person as Constructor parameter and then creates the object, is this right?

5.For the SimpleInjector I stared using it a long time ago after having read this post

  1. If I've to use classical Binding for properties, for event binding have I to use Commands? what if I've got a usercontrol that doesn't have a command for it?

in Caliburn I can attach a Message in the form

 cal:Message.Attach="[Event DataLoading] = "[Action Something($eventArgs)"] .

In Catel how should I bound that event??

1
Me personally use a VieModel base class. And that's all the framework I need really. Why do you use framework?hkon
To separate View / Viewmodel, use of IoC and so on... I know I can have it the same way with ViewModel class but there're out-of-box feature I use and I like just conventionsadvapi
@hkon A ViewModelBase is just a very small detail of MVVM. Technically speaking, you are correct, but Catel provides a lot of convenience for large applications (nested user controls, mappings between model / view model, auditing, command managers (application-wide commands)). You don't have to write any code or unit tests to use this in your apps when using an fx instead of your own VMB.Geert van Horrik

1 Answers

1
votes
  1. No, Catel can work with any model. There are just some conveniences that you get for free if you model implements IEditableObject, INotifyPropertyChanged, IDataErrorInfo, etc
  2. Grids are mostly bound to a list of objects, you shouldn't create a separate view model for each row to keep performance in mind
  3. Caliburn is convention based, Catel is not (for the bindings). You should use regular bindings.
  4. Yep, "of course"
  5. Yes, but you should ask yourself why you want to do this and if you want to do this. Catel works out of the box for you, only change when you have really good reasons.

btw. you might be interested in Orchestra, it's a shell we built on top of Catel for WPF apps (NET 40 and NET 45) which contains a lot of nice feature such as fully customizable keyboard shortcuts, splash screen, etc)

Response to Update #1

3.1: See EventToCommand or any of the many other behaviors and triggers that ship with Catel.

  1. Benchmarking is very good, but you should keep in mind how much you are actually doing. You are probably injecting 2 / 3 vm's at most a second, you won't notice any difference. But if you really want to, check out this documentation on how to replace the default components.

  2. You can still use validation but you must implemented it inside your view model. This is complex for your grids, so then it might be best to create a wrapper that can validate itself. So you could indeed create a ValidatablePerson class that will validate the person and wraps it's properties (or just implements the validation only). Can easily be done using T4 templates.