Current filter:
                                You should refresh the page.
                                  • Hello,
                                    I am working on MVVM the application based od Prism library and using Unity IoC container for instantiating almost everything. So ViewModel are descendant of PRISM's BindableBase.

                                    I my application I use DevExpress library and I would like to use your MVVM services. I have read this https://documentation.devexpress.com/WPF/17450/MVVM-Framework/Services/Services-in-custom-ViewModels. But the way hou can I use Dx services is very uncomfortable for me.

                                    Is there any possibility to use your services in more IoC friendly way, in example register them at startup

                                    [C#]
                                    container.RegisterSingleton<IMessageBoxService, DXMessageBoxService>();

                                    and then simply inject them into ViewModel?

                                    [C#]
                                    public MyViewModel(IMessageBoxService messageBoxService) { ... }

                                1 Solution

                                Creation Date Importance Sort by

                                Hello Karel,

                                Yes, several DXServices can be defined on the application level, but not all of them - for example, NavigationService is bound to a navigation control so it has to be defined on a view level.
                                Also it is much more convenient to define a service facade to reduce amount of injected parameters.

                                So you need:

                                1. Define services in the Application Resource
                                2. Define a ServiceFacade and register it in a IoC container
                                3. Inject or resolve the facade at any place
                                The sample project is attached.

                                Thanks,
                                Mikhail

                                • Karel Král Scia 07.29.2018

                                  Thank you very much for your example. I will easy recreate this for Unity.

                                  One more question: Why are you using in your example keys ("NotificationService") when retrieving service? In Dx documentation are keys not used.

                                  [C#]
                                  _notificatorService = container.GetService<INotificationService>("NotificationService");

                                  https://documentation.devexpress.com/WPF/17450/MVVM-Framework/Services/Services-in-custom-ViewModels

                                • Mikhail Shubin [DevExpress MVP] 07.29.2018

                                  You are welcome, Karel.
                                  Yes, you're right - for a single service kind the GetService method parameter is optional.
                                  So it can be:

                                  [C#]
                                  _notificatorService = container.GetService<INotificationService>();

                                  Thanks,
                                  Mikhail

                                • Kirill (DevExpress Support) 07.30.2018

                                  Hello Karel,
                                  Let me slightly clarify the approach with the key Mikhail used. As you may know, it's possible to define several services of the same type, for example, within one View. It's necessary to distinguish these services to be able to access only a particular service. In this case, you need to define keys for each service and access them as Mikhail demonstrated. This approach is common both for ViewModelBase class descendants and for custom ViewModels. So, it's described in the Services in POCO objects article instead.

                                  Thanks,
                                  Kirill

                                • Karel Král Scia 07.30.2018

                                  Thank You, Kirill, I understand. When I use only one service, there is no key needed, when using multiple services of the same type, you need a key.

                                • Kirill (DevExpress Support) 07.30.2018

                                  You are welcome!