WPF Custom Dialogs - Part 1 [Dialog Service]

  Рет қаралды 23,703

ToskersCorner

ToskersCorner

6 жыл бұрын

In this video we will cover creating an MVVM friendly dialog service for our WPF application. There many more things we may want to do for specific application, and specific goals, so this video covers a general concept of tackling a dialog service in WPF.
Since I don't often to dialogs in WPF (I normally just use the ugly windows dialogs) I did some searching on the internet to influence the direction of my video. Below is a link to an article I found very useful, but overall I decided to go a different direction on some things -- and I hope you like them.
www.c-sharpcorner.com/article...
Window.xaml - pastebin.com/Heu2LiX9
MainWindowVM - pastebin.com/b30Gt1YZ
DialogService (With interface) - pastebin.com/EEk7Vi1z
IDialogWindow - pastebin.com/DfWefMcu
DialogVMBase - pastebin.com/ZYX5P1XX
DialogWindow.xaml - pastebin.com/UJAZRae1
** Tip Jar **
Paypal: toskerscorner@outlook.com
BTC: 3DkvwvcQ8Vt2U84jdtEhNBx2Ueai3Xttmu
ETH: 0xFf79A145e1ED6F538607Ec374968e605cbea758b
BCH: qqpgrnzuhc5hav4e79m8nfhmugs46jtl0ujxcu0tj5
LTC: MHXQmJA3hkwTPeArB9QPNkcLiHQx723yMb

Пікірлер: 16
@xVidarx18
@xVidarx18 5 жыл бұрын
Thank you very much! Love it that you zoom around to the importent parts and dont show the screen as a whole! Keep on Rocking!
@freddyflares2757
@freddyflares2757 5 жыл бұрын
Good series, I recommend any aspiring WPF MVVM developer walk through this and make their own skeleton app.
@283518
@283518 Жыл бұрын
Good tutorial, the only confusing part was DialogWindow : Window, IDialogWindow, but i got it eventually, since its (DataConext ) defined in the interface....it does appear like something changed between when you made this video and the updates in C#/WPF, so it has to be defined now explicitly? it was giving errors when i didnt define anything... because ContentControl doesn't appear to have a DataContext by default anymore, so i had to initialize it myself. If anyone is looking for it, just search the below commend threads, i posted it two times. Thanks again for this MVVM example, im starting to get the hang of it now!
@VinuP2023
@VinuP2023 5 жыл бұрын
Thanks much.
@otello1238
@otello1238 5 жыл бұрын
Nice idea but I was looking for the separation of view from vm. You are creating DialogWindow in DialogService class which means that vm has to reference view. But otherwise nice job.
@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.
@283518
@283518 Жыл бұрын
in the next video he makes YesNoDialogViewModel class, to close it he makes it close with a result CloseDialogWithResult(window, DialogResults.Yes); when the command is executed. You can then use the returned result in an if statement to do what you like with what option the user chose. If its the ok option no real need for the if statment as it just returns undefined....so you would just acknowledge that the button is pressed
@josegregoriomoyaurpin3949
@josegregoriomoyaurpin3949 5 жыл бұрын
Hi dude, great job... i have a litle problem with IDialogWindow, the DataContext dont exist rigth now in ContentControl, i don't why.. i change the name for Content, and that it's implement for ContentControl.
@283518
@283518 Жыл бұрын
for the DialogWindow codebehind do this: public partial class DialogWindow : Window, IDialogWindow { private DialogViewModelBase _dialogViewModelBase; public DialogWindow() { InitializeComponent(); DataConext = _dialogViewModelBase; } public object DataConext { get { return DataConext; } set { Content = value; } } } i think the datacotext was removed from the content control at some point in time
@mcgyverbasaya4152
@mcgyverbasaya4152 3 жыл бұрын
where is the demo?
@andreiandrew9953
@andreiandrew9953 Жыл бұрын
this is so poorly explained in some manners, for example, what is the binding used for DialogWindow? How does it integrate with main window?
@283518
@283518 Жыл бұрын
do this for the DialogWindow public partial class DialogWindow : Window, IDialogWindow { private DialogViewModelBase _dialogViewModelBase; public DialogWindow() { InitializeComponent(); DataConext = _dialogViewModelBase; } public object DataConext { get { return DataConext; } set { Content = value; } } }
@283518
@283518 Жыл бұрын
To explain it in laymans terms (i also prefer laymans terms just fyi ;D) You first have the main window, from the main window you click a button which triggers a command, the command from the main window generates a new dialog window (DialogWindow ). Within this dialog window now, there is a content control, this contentControl allows you to add a userControls to it, he create a Ok dialog and Yes no dialog, each of these userControls can be attached to the contentControl. This is done by setting the contentControl content to the dataContext...which is the class DialogWindow i posted below in my other comment
WPF Custom Dialogs - Part 2 [Dialog Controls]
12:22
ToskersCorner
Рет қаралды 11 М.
Schoolboy - Часть 2
00:12
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 4,5 МЛН
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 126 МЛН
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:40
CRAZY GREAPA
Рет қаралды 33 МЛН
How to show a WPF dialog using MVVM in C# with a mediator
21:53
David Anderson
Рет қаралды 47 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 118 М.
Why The Windows Phone Failed
24:08
Apple Explained
Рет қаралды 234 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 779 М.
C# WPF - Commands [Part 1 Intro + Singular Commands]
17:32
ToskersCorner
Рет қаралды 50 М.
Popup / Modal - WPF UI COMPONENT WORKSHOP
16:21
SingletonSean
Рет қаралды 15 М.
Page Navigation In WPF Using a Frame Control in C#
33:15
Tactic Devs
Рет қаралды 52 М.
Schoolboy - Часть 2
00:12
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 4,5 МЛН