WPF Custom Dialogs - Part 2 [Dialog Controls]

  Рет қаралды 11,138

ToskersCorner

ToskersCorner

6 жыл бұрын

In this video we already have completed our dialog service objects. Now want to build upon our implementations to create some simple dialogs -- in this case an Alert dialog and YesNo dialog.
App.xaml - pastebin.com/NKEhT7AY
MainWindowVM - pastebin.com/HWVSHtLQ
YesNoVM- pastebin.com/dLASkUz7
YesNoView - pastebin.com/wVa6wHmQ
AlertVM - pastebin.com/UryMRZdS
AlertView - pastebin.com/Hfmpfdce
Complete Source Code on Github:
github.com/Joben28/WpfDialog
** Tip Jar **
Paypal: toskerscorner@outlook.com
BTC: 3DkvwvcQ8Vt2U84jdtEhNBx2Ueai3Xttmu
ETH: 0xFf79A145e1ED6F538607Ec374968e605cbea758b
BCH: qqpgrnzuhc5hav4e79m8nfhmugs46jtl0ujxcu0tj5
LTC: MHXQmJA3hkwTPeArB9QPNkcLiHQx723yMb

Пікірлер: 35
@AiguretDuren
@AiguretDuren 5 жыл бұрын
Nicely done. Thank you!
@domeanterai
@domeanterai 6 жыл бұрын
Nice video bro.. help me a lot!
@sorushkhajepor6717
@sorushkhajepor6717 5 жыл бұрын
Good Job
@shaihulud4515
@shaihulud4515 4 жыл бұрын
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!
@productionready9375
@productionready9375 5 жыл бұрын
Good!
@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!
@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
@maikborchardt5692
@maikborchardt5692 4 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@283518 thanx so much+
@Arkios366
@Arkios366 4 ай бұрын
@@283518 does not work canExecute = canExecute ?? ( => true);
@smailagr1279
@smailagr1279 4 жыл бұрын
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 !!!
@randypenajimenez3893
@randypenajimenez3893 4 жыл бұрын
Is it recommended to use Window control as modals or dialogs in a Custom Control Library?. Thanks in advance.
@charmantle737
@charmantle737 Жыл бұрын
does anyone know how to return the dialog results into a variable in the main window file? (not the MainWindowViewModel)
@anaibrahim4361
@anaibrahim4361 3 жыл бұрын
great work but why this MVVm is so complicaed just to show a dialog we have to go all that way
@zerosandones7547
@zerosandones7547 3 жыл бұрын
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 Жыл бұрын
I had the same question, but apparently setting DialogResult property triggers a Close() method
@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*
@mieng106
@mieng106 4 жыл бұрын
Your Github link doesn't work, can you please fix?
@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()) { } } }
@Grv9098
@Grv9098 4 жыл бұрын
Github link is not working.
@psyxiatros1
@psyxiatros1 5 жыл бұрын
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 ?
@josegregoriomoyaurpin3949
@josegregoriomoyaurpin3949 5 жыл бұрын
Explain and code in the correct way, take a little time dude
@Arkios366
@Arkios366 4 ай бұрын
RelayCommand in tutorial not working at all
@diegocantelli
@diegocantelli 2 жыл бұрын
Good content, but there's a lot of good questions not answered here in the comments. That means something...
WPF Custom Dialogs - Part 1 [Dialog Service]
11:53
ToskersCorner
Рет қаралды 23 М.
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 42 МЛН
I Can't Believe We Did This...
00:38
Stokes Twins
Рет қаралды 95 МЛН
WPF Data Triggers W/ Data Templates
6:46
ToskersCorner
Рет қаралды 8 М.
WPF Custom User Control + Dependency Properties
11:12
ToskersCorner
Рет қаралды 56 М.
View Model Communication/Messaging - EASY WPF (.NET 5)
8:42
SingletonSean
Рет қаралды 18 М.
C# WPF - Commands [Part 1 Intro + Singular Commands]
17:32
ToskersCorner
Рет қаралды 50 М.
SimpleWPF - WPF Library, Navigation, templating, commanding.
10:13
ToskersCorner
Рет қаралды 4,8 М.
WPF C# Professional Modern Flat UI Tutorial
36:44
Payload
Рет қаралды 797 М.
C# WPF Tutorial - Using INotifyPropertyChanged
22:01
ToskersCorner
Рет қаралды 48 М.
A Simpler Way to See Results
19:17
Logan Smith
Рет қаралды 100 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 252 М.
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 42 МЛН