How to show a WPF dialog using MVVM in C# with a mediator

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ •

  • @hussainhussaini2267
    @hussainhussaini2267 3 роки тому +2

    I was searching weeks for this solution. Thank you!

  • @kajij
    @kajij 5 років тому +2

    Thanks for providing the corrected video in your description!

  • @ryanweldin553
    @ryanweldin553 8 років тому +30

    Love your videos, but the audio is very low even with max volume on several of my devices/computers. Can this be improved? Thank you.

    • @DX7Dev
      @DX7Dev  7 років тому +1

      I believe I have corrected this on newer videos. I will monitor this!

    • @stevenaughton9372
      @stevenaughton9372 5 років тому +3

      This is more of a problem because we have set the playback volume to the max, and when the ads play they are super loud.

    • @watherby29
      @watherby29 3 роки тому

      I also can't hear the audio watching the first Bourne on the small player here on the right.

  • @ProgrammingMadeEZ
    @ProgrammingMadeEZ 8 років тому +4

    Good to see you posting again.

  • @bomfirit75
    @bomfirit75 3 роки тому +1

    Thanks. Your tutorial helped me a lot.

  • @EricAnastas
    @EricAnastas 7 років тому +3

    This is nitpicking, but this message (10:07) should be something like "is already mapped to type {Mappings[typeofTViewModel]}" to show the current mapping not the new requested mapping

  • @alonlevi80
    @alonlevi80 3 роки тому +2

    Thanks for the detailed video. Just started to lern WPF with MVVM. Haven't found a single example for creating a Modal dialog..... why not start from simple yet not perfect way of implementing it and then develop it more and more?? This is really frustrating for me...

  • @MrEvgeny1984
    @MrEvgeny1984 8 років тому +2

    Thank You for sharing the idea, one problem that I see, that your approach can only work with windows applications. My requirement was to implement it in context of core library to use it with wpf and also xamarin plattforms.
    So I have used an other approach by using the Action class and Callbacks.

    • @DX7Dev
      @DX7Dev  8 років тому

      I haven't built a Xamarin application, but you would have to adapt a solution for it. The concept is the same: create an abstraction by defining the appropriate interfaces, and create a mediator to handle the actual display of the dialog. A single solution for both Xamarin and WPF could be tricky if there isn't any commonality between them, but probably very possible. I would have to take a deeper look at Xamarin to be more helpful.

    • @seemovielove3597
      @seemovielove3597 4 роки тому

      can you share your code for your approach using action and callbacks? Thanks

  • @FuzzyDPozzy
    @FuzzyDPozzy 3 роки тому +1

    It freaking worked!!! unbeliavable :d:D :D :D

  • @teamRizek
    @teamRizek 8 років тому +1

    I'm glad you are back!

  • @Aram198624
    @Aram198624 6 років тому

    It was quite to the point, well done!

  • @pimor2315
    @pimor2315 8 років тому +2

    Very nice, I like the idea. I see only one issue. owner will always be read as null. I have modified the constructor and owner field so I can set it later, however I'm not sure if i should do that.

    • @DX7Dev
      @DX7Dev  8 років тому

      +Piotr Morawski You set the owner in App.xaml when you instantiate the dialog service via its constructor. Typically to MainWindow. Shouldn't be null. It would be null in a unit test though, since there is no ui/owner

    • @pimor2315
      @pimor2315 8 років тому

      DCOM Engineering, LLC Yes I know, however later you set MainWindow. For example if I want to set startuplocation of the dialog to a parentcenter, it will not work, because the owner is null. Any ideas?

  • @pidunate
    @pidunate 2 роки тому +2

    Great content, but the audio is unusually low.

  • @stephendougherty9383
    @stephendougherty9383 8 років тому

    really liked this approach - my only issue is incorporating it with MEF. Still struggling to get my head around a lot of WPF and MVVM concepts

    • @DX7Dev
      @DX7Dev  8 років тому

      If you can elaborate I can probably help with your MEF issue.

    • @stephendougherty9383
      @stephendougherty9383 8 років тому

      Thanks for the reply - I have one more thing to try and figure it out on my own, but will certainly ask if it does not work

  • @EnimaIffets
    @EnimaIffets 8 років тому +2

    Very very nice !!
    I would give you 1000 "thumbs up" if it was possible :-)
    and good to see you posting again, long time i was waiting for new tutorials!

    • @DX7Dev
      @DX7Dev  8 років тому

      More to come.. I have a list..

  • @francoisdeklerk1266
    @francoisdeklerk1266 7 років тому +5

    Volume?

  • @wittttttt
    @wittttttt 6 років тому

    12:12 Is it really necessary? Isn't viewModel disposed with the view (after it's closed)? Which means that all event handlers are disposed as well, aren't they? Am I missing something? Can you please explain?

    • @ondrejexner3688
      @ondrejexner3688 6 років тому

      If you don't need the viewModel anymore then yes, it gets disposed. But there are often situations when you need the data from the dialog window returned. For example: create_customer/order/etc dialog. Thats why you create the viewModel before calling the ShowDialog method.

  • @willijd4
    @willijd4 6 років тому +1

    Great video! Thanks for linking to your project. One question, why does the IDialog interface need a reference to the Window Owner?

  • @Quadrition333
    @Quadrition333 5 років тому

    How do I implement dialogService in opened dialog, if I want to open more dialogs from already opened dialog?

  • @edyzere
    @edyzere 7 років тому

    I love your framework and using it in my proyect thanks a lot. I have two questions with this video. How can adapt the code if the owner is a user control instead of a window. And how can i adapt it if a have to get two strings back from the dialog like if i want to use it as a login form? Thanks in advance.

  • @scotolivera8207
    @scotolivera8207 3 роки тому

    Thanks, is it possible to fix the download link for the source code?

  • @handypda
    @handypda 2 роки тому

    Good work!

  • @Ногабезхатька
    @Ногабезхатька 7 років тому +5

    can`t hear anything

  • @seemovielove3597
    @seemovielove3597 4 роки тому

    Do you have a service for calling modeless dialog? Thanks

    • @DX7Dev
      @DX7Dev  4 роки тому

      I don't, but it would be pretty easy to write one using events or a mediator. You can take this same concept and try and write your own :)

  • @kidsfunvideoland
    @kidsfunvideoland 8 років тому

    Thanks for your video.
    I have used Prism interaction triggers to open popup. What are the benefit of using Dialog service (your method) over prism interaction?
    Which one you recommend?

  • @mrtreynobles
    @mrtreynobles 6 років тому

    Hi there - I really enjoy your videos. Very informative. I'm trying to implement a solution like this with a unity bootstrapper but I'm struggling on figuring out how to implement it in the bootstrapper. It might be worth noting that I'm using Prism as the mvvm framework. I know that I can load the initialize the dialog service in the main window viewmodel constructor but I know that there is probably a better way to do it in the bootstrapper. Any ideas?

  • @davegdn
    @davegdn 4 роки тому

    Excellent but very low volume, had to pump up volume level to hear a little

    • @DX7Dev
      @DX7Dev  4 роки тому

      There is a link in the description to a corrected video.

  • @ginanjarbambang7122
    @ginanjarbambang7122 5 років тому +1

    very nice, but this is very hard to me, only to show dialog. :)

  • @Joel4JC
    @Joel4JC 6 років тому +1

    You show a link in the description with a Video with the corrected audio, why can't you just upload the Video with the corrected audio here?

  • @yanapryimak5469
    @yanapryimak5469 7 років тому

    Why don't you show the result in the end?

  • @chhampionsjourney
    @chhampionsjourney 4 роки тому

    After uploading did you ever hear the voice ....its very low

  • @themanbehindthescenes364
    @themanbehindthescenes364 6 років тому

    I am a beginner at WPF and in C#, please I have many questions about MVVM and it would be great if you can help me, first What is MVVM ? and why are we writing so much code just to display a simple dialog ??! aren't there suppose to be some built-in classes that takes care of all that background work like in android studio and java ??? is this truly necessary ?? I've downloaded your source code and didn't understand a thing from the code. what can I do to understand what the hell is going on ?

    • @WesleysFishClub
      @WesleysFishClub 6 років тому

      MVVM Stands for Model - View - ViewModel and is just a design pattern to build UI applications. We use this pattern to seperate UI, Logic and data which makes code re-usable, dynamic and easily unit testable. By implementing the DialogService shown in the video, you're avoiding tight coupling between your UI (View) and logic (ViewModel).
      The code shown in the video might be complex to understand if you're unfamilar with concepts such as abstraction or generics.
      Follow and listen to understand whats happening.

    • @DX7Dev
      @DX7Dev  6 років тому

      The primary reason for the dialog abstraction is the unit testing of the view model. You can't have dialogs showing in a unit test, and especially so in a build server. Testability, reusability and separation of logic from the view is the primary purposes of a view model. If you were writing a small CRUD application with minimal logic and no unit tests, something like this is not necessary, but its an essential pattern in medium to large code bases

    • @themanbehindthescenes364
      @themanbehindthescenes364 6 років тому

      Okay but I don't understand the code, where can I start with the basics of MVVM ?

    • @DX7Dev
      @DX7Dev  6 років тому

      See my MVVM session 1, intro video

  • @sha.e.sengineeringsolution1205
    @sha.e.sengineeringsolution1205 4 роки тому

    How to handle dialog with ( Save, Don't Save ,Cancel )

    • @DX7Dev
      @DX7Dev  4 роки тому

      Same way but you model your view appropriately to have that information about the dialog, such as a property with an enum that gets set

  • @lufog
    @lufog 5 років тому +1

    What? I don't hear you!

    • @DX7Dev
      @DX7Dev  5 років тому +1

      There is a corrected video in the description

  • @mohammedkarro4383
    @mohammedkarro4383 5 років тому +1

    Noice!

  • @anaibrahim4361
    @anaibrahim4361 3 роки тому

    is that all just to pop up a dialog !!!

  • @jamesshaw4089
    @jamesshaw4089 6 років тому

    Definitely easy to follow along with. The volume on the otherhand...that's another story. I had to play the video on my TV and turn it's volume up to 100% just to hear it. Good job otherwise!

    • @DX7Dev
      @DX7Dev  6 років тому

      I added a corrected volume video link in the description.

  • @M7829-f7q
    @M7829-f7q 4 роки тому

    Please fix the volume.

  • @signon77
    @signon77 5 років тому

    Potentially this might be a good video. Couldn't hear a thing though.

    • @DX7Dev
      @DX7Dev  5 років тому

      There is a fixed audio version in the description

  • @arkadybron1994
    @arkadybron1994 2 роки тому

    I cant hear what you're saying.

    • @DX7Dev
      @DX7Dev  2 роки тому +1

      Fixed the audio and there's a new link in the description

  • @TheDotnettex
    @TheDotnettex 2 роки тому

    WHAT????? HELLO??? IS THERE AUDIO ON THIS??? CAN YOU SPEAK UP???? Another person that has no idea how to set the correct audio level in a video....

    • @DX7Dev
      @DX7Dev  2 роки тому

      There is a link to a fixed video in the video description. Sorry about that.