Click here to Skip to main content
15,559,962 members
Home / Discussions / WPF
   

WPF

 
Questionstill shown DialogService until error exists in user input and dont press Cancel Pin
MrKBA7-Feb-17 22:14
MrKBA7-Feb-17 22:14 
AnswerRe: still shown DialogService until error exists in user input and dont press Cancel Pin
Richard Deeming8-Feb-17 3:04
mveRichard Deeming8-Feb-17 3:04 
GeneralRe: still shown DialogService until error exists in user input and dont press Cancel Pin
MrKBA8-Feb-17 22:20
MrKBA8-Feb-17 22:20 
GeneralRe: still shown DialogService until error exists in user input and dont press Cancel Pin
Richard Deeming8-Feb-17 22:53
mveRichard Deeming8-Feb-17 22:53 
GeneralRe: still shown DialogService until error exists in user input and dont press Cancel Pin
MrKBA8-Feb-17 23:10
MrKBA8-Feb-17 23:10 
GeneralRe: still shown DialogService until error exists in user input and dont press Cancel Pin
Richard Deeming8-Feb-17 23:16
mveRichard Deeming8-Feb-17 23:16 
GeneralRe: still shown DialogService until error exists in user input and dont press Cancel Pin
MrKBA9-Feb-17 0:47
MrKBA9-Feb-17 0:47 
GeneralRe: still shown DialogService until error exists in user input and dont press Cancel Pin
Richard Deeming9-Feb-17 1:00
mveRichard Deeming9-Feb-17 1:00 
So you're using the DevExpress MVVM framework?

Looking at the documentation[^], your command can take a CancelEventArgs parameter to allow it to keep the dialog open:
Note that dialog commands take a CancelEventArgs object as a parameter. When dialog commands are invoked, the dialog is closed by default. To prevent this behavior, it is necessary to set the CancelEventArgs.Cancel parameter to True.

C#
var createCommand = new UICommand
{
    Id = MessageBoxResult.OK,
    Caption = Properties.Resources.CstOk,
    IsCancel = false,
    IsDefault = true,
    Command = new DelegateCommand<CancelEventArgs>(CreateRole, CanCreateRole)
};

private bool CanCreateRole(CancelEventArgs e)
{
    // NB: IsNullOrWhiteSpace(value) is more efficient than IsNullOrEmpty(value.Trim()),
    //     and avoids a NullReferenceException if the string is null.
    return !string.IsNullOrWhiteSpace(_roleViewModel.RoleName);
}

private void CreateRole(CancelEventArgs e)
{
    _roleViewModel.AcceptChanges();
    if (ValidateData(_roleViewModel.RoleName.Trim()))
    {
        AddRole(_roleViewModel.RoleName, _roleViewModel.RoleDescription);
    }
    else
    {
        // Keep the dialog open:
        e.Cancel = true;
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: still shown DialogService until error exists in user input and dont press Cancel Pin
MrKBA9-Feb-17 2:41
MrKBA9-Feb-17 2:41 
QuestionWPF: DataGridCheckboxColumn when one checkbox is checked, check another checkbox in same row Pin
Mark McArdle6-Feb-17 4:04
Mark McArdle6-Feb-17 4:04 
AnswerRe: WPF: DataGridCheckboxColumn when one checkbox is checked, check another checkbox in same row Pin
Richard Deeming6-Feb-17 8:55
mveRichard Deeming6-Feb-17 8:55 
PraiseRe: WPF: DataGridCheckboxColumn when one checkbox is checked, check another checkbox in same row Pin
Mark McArdle7-Feb-17 3:07
Mark McArdle7-Feb-17 3:07 
QuestionStyle User Control In Another Assembly Pin
Kevin Marois2-Feb-17 7:54
professionalKevin Marois2-Feb-17 7:54 
AnswerRe: Style User Control In Another Assembly Pin
Pete O'Hanlon2-Feb-17 8:12
mvaPete O'Hanlon2-Feb-17 8:12 
GeneralRe: Style User Control In Another Assembly Pin
Kevin Marois2-Feb-17 8:13
professionalKevin Marois2-Feb-17 8:13 
GeneralRe: Style User Control In Another Assembly Pin
Kevin Marois2-Feb-17 8:50
professionalKevin Marois2-Feb-17 8:50 
QuestionTelerik GridViewComboBoxColumn Pin
eddieangel25-Jan-17 13:29
eddieangel25-Jan-17 13:29 
AnswerRe: Telerik GridViewComboBoxColumn Pin
Graeme_Grant28-Jan-17 3:23
mvaGraeme_Grant28-Jan-17 3:23 
QuestionDataGrid DataGridComboBoxColumn Enum Descriptions Pin
Kevin Marois24-Jan-17 7:22
professionalKevin Marois24-Jan-17 7:22 
AnswerRe: DataGrid DataGridComboBoxColumn Enum Descriptions Pin
Afzaal Ahmad Zeeshan24-Jan-17 7:46
mveAfzaal Ahmad Zeeshan24-Jan-17 7:46 
QuestionWPF DataGrid Extended Pin
Kevin Marois23-Jan-17 11:00
professionalKevin Marois23-Jan-17 11:00 
AnswerRe: WPF DataGrid Extended Pin
Richard Deeming23-Jan-17 11:25
mveRichard Deeming23-Jan-17 11:25 
GeneralRe: WPF DataGrid Extended Pin
Kevin Marois23-Jan-17 11:28
professionalKevin Marois23-Jan-17 11:28 
QuestionComboBox Restore Saved Item Pin
Kevin Marois20-Jan-17 11:06
professionalKevin Marois20-Jan-17 11:06 
AnswerRe: ComboBox Restore Saved Item Pin
Afzaal Ahmad Zeeshan20-Jan-17 12:20
mveAfzaal Ahmad Zeeshan20-Jan-17 12:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.