More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Enviro++
更好教育论坛
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post Go to first unread
hong  
#1 Posted : Thursday, February 9, 2017 9:14:12 PM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 11/23/2008(UTC)
Posts: 522

Show a dialog with Caliburn Micro and get DialogResult

Open a dialog with the WindowManager from caliburn micro
Code:
vm = new DialogViewModel();
var result = _windowManager.ShowDialog(vm, null, null);

The ShowDialog method of WindowManager doesn't return a DialogResult. But we need a DialogResult when the user close the dialog with OK or Cancel button.

Method 1:
In Caliburn Micro in dialogViewModel which inherits from Screen you can do:

Code:
TryClose(true); // for OK
or
TryClose(false); // for Cancel


Method 2:
Use a property MyDialogResult or a flag such as IsCancelled in view model

Code:
if (dialogViewModel.MyDialogResult == DialogResult.OK)...

    public void Ok()
    {
        MyDialogResult = DialogResult.OK;
        TryClose();
    }

    public void Cancel()
    {
        MyDialogResult = DialogResult.Cancel;
        TryClose();        
    }


Code:
    if (dialogViewModel.IsCancelled) {
        // ...
    } else {
        // ...
    }

Edited by user Thursday, February 9, 2017 9:14:58 PM(UTC)  | Reason: Not specified

Sponsor
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.