Current filter:
                                You should refresh the page.
                                  • I came across your FolderBrowserDialogService the other day and thought maybe we could use that in our PRISM application. But I am confused why there is some view behaviours required and some overly complicated ViewModel setup to get it working. Why is their just not a service I can register with my unity container and bring it in via my ViewModel constructor? Why do I need a whole container for each ViewModel?

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,
                                Many of our services are bound to the View part. For example, FrameNavigationService requires to be attached to the NavigationFrame element, TabbedDocumentUIService should have a reference to the target DocumentGroup etc. So, they cannot be registered globally in a simple way but should be registered at the level of a corresponding ViewModel.

                                If you want to use our services with a certain IoC container, you can use the approach Michail described in the following thread: MVVM services and IoC container. Please refer to it for more details.

                                Thanks,
                                Kirill

                                • James Baker 08.15.2019

                                  But what about FolderBrowserDialogService? Why is this bound to the View? I didn't see a need?

                                • Kirill (DevExpress Support) 08.16.2019

                                  Hello James,
                                  All our services use the same registration mechanism. However, certain services as MessageBoxService can be registered globally using the static ServiceContainer.Default.RegisterService method. FolderBrowserDialogService is also the case and it's not necessary to use individual containers for it:

                                  [C#]
                                  ServiceContainer.Default.RegisterService(new FolderBrowserDialogService());

                                  This technique is mentioned in the Services -> Getting Started article. We will improve our documentation to include a complete list of such services.

                                  Thanks,
                                  Kirill

                                • James Baker 08.19.2019

                                  Why does this suggest attached a behaviour in XAML: https://documentation.devexpress.com/WPF/17444/MVVM-Framework/Services/Getting-Started?

                                  Why cannot I use my container to add the service? And just put it in the constructor of my ViewModel? I don't want to have some static reference that it is hard to mock etc.

                                • Andrey Marten (DevExpress Support) 08.20.2019

                                  Hello James,

                                  Thank you for your patience.

                                  Our services are not the same as services in IoC. Their main purpose is to operate with a view's elements at the view model level. That is why, in the case of most our services, you need to define these services at the view level. The Getting Started help topic describes this basic usage of our services. As Kirill described above, we will extend the note related to using services at the application level in the future and will add a list of services that can be used this way.

                                  >> Why cannot I use my container to add the service? And just put it in the constructor of my ViewModel?
                                  As our services are not designed similarly to services that are used in IoC, their usage is also different. They register and unregister themselves and should not be registered/unregistered manually. Even though it's theoretically possible to register them in a custom container, they weren't designed for this task.

                                  >>I don't want to have some static reference that it is hard to mock etc.
                                  If your concerns here relate to writing corresponding unit tests, you still can use our services for this purpose. Please refer to the corresponding section in the Getting Started article.

                                  Thanks,
                                  Andrey

                                • James Baker 08.21.2019

                                  It's just too complex and I won't be using it in it's current form. I just saw them and thought we could replace our own.

                                  A lot of people will surely be using an IoC container already and it makes sense it would work with them. This link between the view and view model sounds more of a hard link that it should in my opinion, they should be loosely coupled.