MVVM Dialogs: Showing Dialogs in an MVVM Application with a Dialog Service

MVVM Dialogs: Showing Dialogs in an MVVM Application with a Dialog Service

Brian Lagunas

2 года назад

24,126 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Rahul Mathew
Rahul Mathew - 22.11.2021 22:39

I also asked you a similar question about login dialog box and you posted a video for that. Awesome video Brian, we are learning really cool lessons from you. It was only because of you I was able to complete my MVVM project and I landed in my new job.

Ответить
立青
立青 - 08.09.2023 02:22

The video is great, it helped me a lot, thank you❤

Ответить
NicSD
NicSD - 30.04.2023 19:34

I'm not sure if I see how wrapping a dialog with an interface class solves the layer violation caused by opening a dialog from the view model? Shouldn't the dialog be generated by the view?

Ответить
Robert Thurman
Robert Thurman - 24.02.2023 23:25

Another amazing video. I'm still trying to wrap my head around it but there is a ton here that have questions on.... I just need to get use to the abstraction that you are talking about. Again, great video.

Ответить
MIke Drtikol
MIke Drtikol - 17.02.2023 23:56

Can you please share git repo for this ?

Ответить
M. Moosa
M. Moosa - 25.01.2023 19:22

Having names like "ExecuteShowDialog" or "ShowDialog" inside VM isn't itself wrong? because essentially we are exposing "What we are doing on UI" to the View Model. It would be worth mentioning that you used this kinda naming for example only...or a video about what kinda naming is allowed in VMs and What's not, or what's a clear no-no and what's Yes-yes etc.. Anyway, Thanks for the video, it was really good!

Ответить
mario fares
mario fares - 10.01.2023 06:18

What if I want to show the Dialog CenterOwner? Using this service means that the dialog does not have an owner. What to do?

Ответить
Md Rahbar Ahmed Khan
Md Rahbar Ahmed Khan - 01.01.2023 08:38

Hi Brain,

Could you please guide us how to implement WPF application on Dual or multiple monitors ?

Ответить
TECHNOCITY VLOGS
TECHNOCITY VLOGS - 21.12.2022 08:00

What would i do if my views resides is within another project in the same solution but can't reference that project?

Ответить
Mahdi MohammadAliPour
Mahdi MohammadAliPour - 18.12.2022 13:07

Thank you for this amazing content. but one thing I couldn't figure it out is this: you created your Dialog Service and the corresponding interface in the "View" project and also your "View Model" is in the same project so you are able to access the class. but if I have my "View Model" in other project how can I access the Dialog Service from "View" project? If I want to use the Dialog Service class I have to add "view" project reference to my "View Model" project which is not ideal from MVVM point of view. if I want to define Dialog Service in "View model" project so I can have access to it then I can't create the instance of the "DialogWindow" Window from "View Model" project. How to overcome this dependencies ? or is allowed to have "DialogService" class that is defined in "View" specifically?

Ответить
Roland Watz
Roland Watz - 30.11.2022 07:07

By following your video and type the code shown in it, I have learnt in this hour more than in the month before. That was a huge motivation - boost. Thank you very very much. And whenever you come to germany - your coffee is for free - forever ;-) !!!!

Ответить
Harvey
Harvey - 27.10.2022 06:20

Thanks, I learned a lot in this video.

Ответить
Jannick Breunis
Jannick Breunis - 19.09.2022 13:52

In what part of the project the dialogservice is located? Is it a public class in the core (viewmodel+model) or is it part of the view? Thanks for the tutorial, I'm going to work out how a viewmodel can initiate another viewmodel with relevant view.

Ответить
Md Rahbar Ahmed Khan
Md Rahbar Ahmed Khan - 22.07.2022 05:20

Hi Brain,
I need help.
Actually I have an Item Control and when I populate the same with data it comes around 50-80 item in the Grid Each Item Control has button. On click of that button I wanted to open popup but that pop-up should be inside the item control area.

Could you please help me

Ответить
Kenneth Fleckenstein Nielsen
Kenneth Fleckenstein Nielsen - 11.07.2022 17:55

I like you approach, but I run into a problem, with how to map the viewmodels to views.
I can ofcause do it in the xaml, under
<DataTemplate DataType="{x:Type controls:QuestionBoxViewModel}">
<controls:QuestionBoxView />
</DataTemplate>

but I want to use the register viewmodels/views, for that, that must be possible somehow..
Thanks good stuff ;-)

Ответить
hoongi jeong
hoongi jeong - 30.05.2022 17:08

always thanks

Ответить
Robbie Norton
Robbie Norton - 14.04.2022 23:29

Excellent video and explanation of how everything works and why etc. I wish everyone did tutorials this clearly!

Ответить
Kashif Mubarak
Kashif Mubarak - 11.04.2022 00:17

Hi Brian, this is so cool and thanks for a thorough explanation throughout the video!
I do have a question though; how to register a viewModel that accepts some parameters?

Ответить
Ria Yukihana Cherry
Ria Yukihana Cherry - 31.03.2022 16:12

Nice video! Thanks for uploading. Solved a lot of my questions regarding MVVM-Dialog coding ethics.

Ответить
Philip
Philip - 29.03.2022 20:21

Hi Brian, nicely explained video. I'm creating an application that has a textbox and a button "search". The searchbutton would open a new dialog. So far so good thanks to your video. But what my app needs is that the input from the textbox is passed as a parameter (or some other way) into the viewmodel of the new dialog, some code would then populate a combobox based on content from the textbox and the selected item is then returned back to the original viewmodel that opened the dialog. Can you help me?

Ответить
Austin Fisher
Austin Fisher - 15.03.2022 20:54

I have an application I'm trying to develop for my company that uses Dialog windows for receiving and returning input from a user to a ViewModel. Is it a better practice to have a DialogueWindow template and inject Views into the window by setting the content? Currently I have each view defined as a window instead of a user control, but I'm not sure if that's the appropriate way to do things. I'm pretty new to MVVM and WPF.

Ответить
murali b k
murali b k - 14.03.2022 21:40

Hi Brain, Thanks for such a great video.. I am working on an application where I need to show a keyboard dialog for user input. I also need to restrict the user to enter a value between min & max range. I have a KaypadViewModel with min, max and userInputValue properties. I followed your video and able to display the keypad but I am not able to figure out how i can exchange data between my KeypadViewModel and MainWindow. Can you please share your thoughts on this? Thanks a lot

Ответить
Gus
Gus - 31.01.2022 16:28

Hi . i love your content . I also have a question . if i close app i want to do some clean up in VM but Destroy is not trigger. How to make it work ? Can you make a short tech answer about that ? Also when i close app not even OnNavigatedFrom. is not triggered . Maybe will be a good subject for a short tech question . Thank you

Ответить
Piotr Gołacki
Piotr Gołacki - 10.01.2022 13:46

Thanks for the video it is really helpful. I wonder is a Dialog Service a part of View or ViewModel? it looks to me as it's neither, because if its part of VM then you call DialogWindow from VM which is violation of MVVM. So isn't it another layer in the MVVM between View and ViewModel? It also looks a s a way to extract code from code-behind to another file? I'm just curious and any insight would be great :)

Ответить
Prakash View
Prakash View - 20.12.2021 13:00

Hi Brain, Thanks for the video. So If I want to pass any data to NotificationDialog ( Data is binded to textblock control), How do i do that?

Ответить
Vladimir Đurić
Vladimir Đurić - 09.12.2021 12:16

Hey Brian, great video as always. I have a question, how to use dialog service to show progress dialog? Need to block clicking other buttons until awaited task finish.

Ответить
torchok19081986
torchok19081986 - 06.12.2021 11:52

I have a tech question : how do i pass ViewModel Object with data to Commandparamter in MVVM in ICommand if i have two diferent types of Model or exists easier approach to achieve that ?

Ответить
YH JEONG
YH JEONG - 30.11.2021 16:15

I trapped into your fingers in thumbnail. I couldn't avoid it.

Ответить
Almir Vuk
Almir Vuk - 28.11.2021 23:43

Looking forward to more videos like these! I am a real fan of your presentation style :)

Ответить
Melsawy
Melsawy - 28.11.2021 23:05

Hi Brian. Appreciate the huge effort and helpful videos you are putting out. I understand that in this video you are implementing a "mini" version of the IDialogService already in Prism. I am currently using the IDialogService in Prism. When I try to .showDialog and specify a Window not a Usercontrol it gives me an error "System.InvalidOperationException: 'Window must be the root of the tree. Cannot add Window as a child of Visual.' Is this because the IDialogService in Prism only allows usercontrols to be injected into a blank window? I believe you might of faced the same issue in your Outlook series right? Would I need to modify the IDialogService in Prism?

Ответить
Solved Plus
Solved Plus - 27.11.2021 14:45

I have a tech quesion,
How can we print documents and pictures with print preview in MVVM
I hope you can help me
thanks in advance

Ответить
taab84
taab84 - 25.11.2021 18:00

How To make "select all" in datagrid with mvvm?

Ответить
Das Fahrer
Das Fahrer - 25.11.2021 01:56

This is really neat, but sometimes it's okay to break the rules to get something simple done and move on. When separation of concerns becomes a religion, it's a concern.

Ответить
Rodrigo Juarez
Rodrigo Juarez - 24.11.2021 01:41

Awesome content, thanks!!

Ответить
Shai Hulud
Shai Hulud - 23.11.2021 22:31

That's so awesome! You inspired me to keep on practicing with C#, and this topic was one of my main questions - always has been. Now, about some time ago, I found my own way of doing this mvvm compatible. Now I am so excited to learn what your approach is! Many of that little step stones on the way to my own solution I learned to overcome thanks to your videos. Now, I am no programmer to make a living out of it, so I cannot allow me to judge on this behalf, but I am a teacher, so I know a thing or two about teaching, didactics, motivating people and the likes. You sir are an absolute brilliant teacher! Thank you!

Ответить
SuessLabs
SuessLabs - 23.11.2021 19:04

Brian, this is a great refresher for Prism's Dialog functionality.
Your timing is perfect for the Prism.Avalonia project. This is literally the last piece for the v8.x upgrade; hard to find free time w/ office work's end of year crunches.

Ответить
William Liu
William Liu - 23.11.2021 06:40

Thanks very much! Looking forward to more fancy WPF skills from here!

Ответить
Jonathan Grenier
Jonathan Grenier - 23.11.2021 04:37

This is really great! I was wondering if you could do something with dependency injection. I see it a lot but I can't seems to find someone to explain and show how to do it easily! Thank you in advance :)

Ответить
Yevheniy Tymchishin
Yevheniy Tymchishin - 23.11.2021 02:31

All that goodness can be achieved by using Prism)

Ответить
Geoff Shotts
Geoff Shotts - 23.11.2021 01:39

Hi: you mentioned you would normally inject the DialogService into the (ViewModel?) constructor. So do you usually only have one instance of a DialogService which is part of the ViewModel construction parameters? Also, is your DialogService a singleton or do you leave the possibility of having multiple instances of DialogService?

Ответить
Iftkwlfb
Iftkwlfb - 22.11.2021 23:33

Hi Brian. Thanks for the great content. What is the best approach to implement drag and drop on a treeview with mvvm?

Ответить
Solved Plus
Solved Plus - 22.11.2021 23:15

awesome, many thanks for your very nice tutorial

Ответить
SuessLabs
SuessLabs - 22.11.2021 20:05

This is a good reminder, thank you. I'm still wrapping up Prism.Avalonia v8.x upgrade and DialogService is the last piece missing, which I'm trying to find time to wrap up.

Ответить
MAHESH
MAHESH - 22.11.2021 18:07

This is how IDailogService in prism works ??

Ответить
Hussain Hussaini
Hussain Hussaini - 22.11.2021 17:44

I asked this almost a year ago! 😆

Ответить
Mosayyeb Ebrahimi
Mosayyeb Ebrahimi - 22.11.2021 17:17

Fascinating!

Ответить
NeutrinoParticle
NeutrinoParticle - 22.11.2021 16:12

Amazing

Ответить
Md Rahbar Ahmed Khan
Md Rahbar Ahmed Khan - 22.11.2021 16:03

I asked this question 😁
Thanks Brain 🙂

Ответить