WPF Custom Dialogs - Part 2 [Dialog Controls]

Поділитися
Вставка
  • Опубліковано 17 жов 2024

КОМЕНТАРІ • 35

  • @shaihulud4515
    @shaihulud4515 4 роки тому +2

    This must be the best explanation I came across so far. But I'd like to come up with two questions:
    1. Why is your view of type usercontrol? Could I also use a window instead? What would I have to change?
    2. Since I'm new to wpf - if you click on "OK", or "YES" / "NO" in the dialogs, the dialogs dont't close. How do I achieve this?
    Thanks, and please keep making those videos!

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

    Is it correct from the MVVM perspective to create one ViewModel inside another(personally I think that your implementation is pretty good and due to composition (one ViewModel inside another) there should not be any problems with coupling)? This makes the return of some from OpenDialog useless 'cause we can just get that result using ViewModel instance

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

    Thank you for uploading. Just a quick question: If my viewModel inherits from DialogViewModelBase, it won't accept my NotifyPropertyChangedBase, since a class can only have one base class. Since I'm new to MVVM, and WPF in general: how would I resolve this? I know, there's tons of info around in the www, but you really know how to explain things!

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

    how is the dialogs closed when the "Yes", "No", or "OK" button is pressed? I'm confused since I haven't seen any .Close() here.

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

      I had the same question, but apparently setting DialogResult property triggers a Close() method

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

    This is a simple alert and YesNo dialog. What about if I want to show a complex dialog that need another service like a DataService and I need to pass it with dependency injection through the constructer. How to do that in a testable way ?? PS: I did it but my solution is not testable i.e I am explicitly working with the view and the container in the ViewModel !!!

  • @maikborchardt5692
    @maikborchardt5692 4 роки тому +5

    could you please share the specific RelayCommand implementation you are using? thank you. Great Video!

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

      I had the same issue, he does not explain it at all!
      Unfortunately you have to go to his github and dig for it in the SimpleWPF master... I only got it to compile after a bunch of work!

    • @283518
      @283518 Рік тому +2

      using System;
      using System.Windows.Input;
      namespace SimpleWPF.Input
      {
      ///
      /// A command implementation
      ///
      ///
      public class RelayCommand : ICommand
      {
      private readonly Action _execute = null;
      private readonly Func _canExecute = null;
      public event EventHandler CanExecuteChanged
      {
      add { CommandManager.RequerySuggested += value; }
      remove { CommandManager.RequerySuggested -= value; }
      }
      public RelayCommand(Action execute, Func canExecute = null)
      {
      _execute = execute ?? throw new ArgumentNullException(nameof(execute));
      _canExecute = canExecute ?? (_ => true);
      }
      public bool CanExecute(object parameter) => _canExecute((T)parameter);
      public void Execute(object parameter) => _execute((T)parameter);
      }
      public class RelayCommand : RelayCommand
      {
      public RelayCommand(Action execute)
      : base(_ => execute()) { }
      public RelayCommand(Action execute, Func canExecute)
      : base(_ => execute(), _ => canExecute()) { }
      }
      }

    • @maikborchardt5692
      @maikborchardt5692 Рік тому +1

      @@283518 thanx so much+

    • @Arkios366
      @Arkios366 7 місяців тому

      @@283518 does not work canExecute = canExecute ?? ( => true);

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

    i followed the tutorial, my hurdle is when the dialog box opens, the ContentControl just shows the class name, *WpfApp1.Dialogs.Alert.AlertDialogViewModel* instead of the message and button
    i've gone through the AlertDialogView and DialogWindow many times i cannot see any difference.. my own thought is i'm trying this in .NET Core vs .NET Framework
    any suggestions?

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

      Found it!
      needed to added a OnStartup override to App.xml, and *DataTemplateManager*

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

    Is it recommended to use Window control as modals or dialogs in a Custom Control Library?. Thanks in advance.

  • @psyxiatros1
    @psyxiatros1 5 років тому +4

    well sorry if i sound stupid because i just started approaching WPF but...
    do you really need 25 mins to make a yes-no dialogue ?

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

    does anyone know how to return the dialog results into a variable in the main window file? (not the MainWindowViewModel)

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

    great work
    but why this MVVm is so complicaed
    just to show a dialog we have to go all that way

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

    Your Github link doesn't work, can you please fix?

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

    Nicely done. Thank you!

  • @Arkios366
    @Arkios366 7 місяців тому

    RelayCommand in tutorial not working at all

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

    Github link is not working.

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

    Nice video bro.. help me a lot!

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

    Good Job

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

    Good!

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

    Anyone has the implementation of relayCommand? and the generic one?

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

      Get it from here github.com/Joben28/SimpleWPF

    • @283518
      @283518 Рік тому

      using System;
      using System.Windows.Input;
      namespace SimpleWPF.Input
      {
      ///
      /// A command implementation
      ///
      ///
      public class RelayCommand : ICommand
      {
      private readonly Action _execute = null;
      private readonly Func _canExecute = null;
      public event EventHandler CanExecuteChanged
      {
      add { CommandManager.RequerySuggested += value; }
      remove { CommandManager.RequerySuggested -= value; }
      }
      public RelayCommand(Action execute, Func canExecute = null)
      {
      _execute = execute ?? throw new ArgumentNullException(nameof(execute));
      _canExecute = canExecute ?? (_ => true);
      }
      public bool CanExecute(object parameter) => _canExecute((T)parameter);
      public void Execute(object parameter) => _execute((T)parameter);
      }
      public class RelayCommand : RelayCommand
      {
      public RelayCommand(Action execute)
      : base(_ => execute()) { }
      public RelayCommand(Action execute, Func canExecute)
      : base(_ => execute(), _ => canExecute()) { }
      }
      }

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

    Good content, but there's a lot of good questions not answered here in the comments. That means something...