At first have to mention that there is no significant difference between WPF development with Oxygene and, for example, WPF development with C#. All WPF-related approaches, advices, tutorials and (unfortunately) bugs are the same for all .NET languages. Even more - same XAML can be used in C# and Oxygene applications. All styles, behaviors and bindings syntax is completely the same for Oxygene and C# (all .xaml files are written in the XAML language regardless of the main application language).
Is there any info, demo, video how to properly develop WPF application with dataabstract using MVVM pattern ?
Unfortunately no. Could you provide a list of questions regarding this theme so I’ll provide answers you need?
However in general words WPF application that uses Data Abstract doesn’t differs conceptually from any other WPF application. In other words data access layer (regardless is it based on Data Abstract, WCF or any other technology) should be separated from ViewModels layer, which, in turn, should be separated from the Views layer.
How (where) to initialize datamodule class in WPF, that any modelview class can access it ?
This is a question of the software architecture area, so there is no answer that will be correct in all situations. For example for simple quick’n’dirty prototype app DataModule can be instantiated directly in the code-behind of the main WPF application form. In more advanced architecture DataModule could be hidden behind an interface that is later injected into instantiated ViewModels using some IoC container.
So WPF application development approaches ae the same for Oxygene and, for example, C#. Also when the Data Access Layer is clearly separated from the other application code layers it is not important (from the application architecture point of view) which exactly technology is actually used to access the data.
Please take a look at http://blogs.remobjects.com/blogs/mh/2012/10/09/p4850
The WPF wizard application shown in this blogpost was created using Oxygene. It uses MVVM and IoC approaches (namely it uses MVVM Light as MVVM helper library and autofac as Dependency Injection container)
And, fwiw, MVVM is just a pattern and does not require a 3rd party framework such as MVVM Light, etc.
Indeed 3rd partly frameworks aren't required to create MVVM applications, but they provide tools and routines intended to make developer's life easier.
By mentioning MVVM Light I didn’t intended to recommend (or to not recommend) any particular library of framework. My intention was to show that creating WPF applications in Oxygene doesn’t differ (approach- and methodology-wise) from creating WPF applications in any other .NET language.
I find the additional frameworks just introducing constructs that are harder to understand (though more general). If you are just starting with MVVM, I would do it without a framework first so that you have a really good understanding of MVVM. THEN maybe move to the frameworks. I suspect MVVMLight, as was mentioned, is the most popular.
Prism is also quite powerful and popular MVVM framework. It well documented and contains a lot of samples to get started with it. Though some of developers can consider it as heavy and suitable for large projects.
I’ve been doing Pascal since Turbo Pascal 1.0. So I’ve spent a lot of time in Pascal and Delphi, also. I haven’t used Delphi for a couple of years now (I have a terrible sense of time, so it might have been longer or shorter). I can’t imagine going back to Delphi. Too restrictive. Xaml is a lot more powerful than the Delphi DFM, etc.
I don’t think there is anything directly analogous to Datamodule. If you want to share code, the best thing is to make a class library and then just “add reference” to it in your projects.
I would put the Viewmodel class in a class library. In fact, I normally create a Viewmodels assembly and a Views assembly so that are completely independent of each other. Then the main app joins the two together using a Page that instantiates the View and the Viewmodel and makes the Page DataContext be the Viewmodel instance.
Thanks for your response.
Can you be more precise ?
I knows how to use reference to other assemblies.
But i don’t know where instantiate shared classes and how to pass reference of that clasess to modelview classes.
Is app class apropriate place ?
I almost exclusively do Silverlight, but I think WPF does the same sorts of things. You can either have an instance of a shared class created by the App or you could create a Resource. Here is what I do for a Page:
type
CategoriesViewmodel = public class
public
constructor;
property Categories : Categories; notify;
end;
MainViewmodel = public class
public
constructor;
property CategoriesViewmodel : CategoriesViewmodel;
end;
implementation
constructor MainViewmodel;
begin
CategoriesViewmodel := new CategoriesViewmodel;
end;
constructor CategoriesViewmodel;
begin
Categories := new Categories;
end;
end.
If I wanted one instance per app, I would create it in the App Startup event handler.
Hope this helps.
(don’t know how to mark up this post so that it doesn’t get rid of my indentation. crap, and it stripped out my markup too. Can’t find anywhere here that says what to do.)