Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:23:30+00:00 2026-06-05T07:23:30+00:00

I currently develop a metro style app using mvvm light framework. I have some

  • 0

I currently develop a metro style app using mvvm light framework.

I have some commands, e.g. DeleteSelectedAppUserCommand. The user must confirm that he really wants to delete the user. So I have written a static Method “ShowMessageBoxYesNo” in the static class “DialogService”.

public static async Task<bool> ShowMessageBoxYesNo(string message, string title)
{
    MessageDialog dlg = new MessageDialog(message, title);

    // Add commands and set their command ids
    dlg.Commands.Add(new UICommand("Yes", null, 0));
    dlg.Commands.Add(new UICommand("No", null, 1));

    // Set the command that will be invoked by default
    dlg.DefaultCommandIndex = 1;

    // Show the message dialog and get the event that was invoked via the async operator
    IUICommand result = await dlg.ShowAsync();

    return (int)result.Id == 0;
}

In the command I want call this method, but I don’t know how…
Is this not possible? Following code doesn’t work!

#region DeleteSelectedAppUserCommand

/// <summary>
/// The <see cref="DeleteSelectedAppUserCommand" /> RelayCommand's name.
/// </summary>
private RelayCommand _deleteSelectedAppUserCommand;

/// <summary>
/// Gets the DeleteSelectedAppUserCommand RelayCommand.
/// </summary>
public RelayCommand DeleteSelectedAppUserCommand
{
    get
    {
        return _deleteSelectedAppUserCommand
            ?? (_deleteSelectedAppUserCommand = new RelayCommand(
            () =>
            {
                if (await DialogService.ShowMessageBoxYesNo("Do you really want delete the user?","Confirm delete")
                {
                    AppUsers.Remove(SelectedEditAppUser);
                }
            },
            () =>
                this.SelectedEditAppUser != null
            ));
    }
}
#endregion

Thanks for help!
Michael

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:23:32+00:00Added an answer on June 5, 2026 at 7:23 am

    If you want to use await in a lambda, you have to mark that lambda as async:

    new RelayCommand(
        async () =>
        {
            if (await DialogService.ShowMessageBoxYesNo("Do you really want delete the user?", "Confirm delete")
            {
                AppUsers.Remove(SelectedEditAppUser);
            }
        },
        () =>
            this.SelectedEditAppUser != null
        )
    

    This creates a void-returning async method which should be usually avoided. But I think it makes sense here, because you’re basically implementing an event handler. And event handlers are the only place where void-returning async methods are normally used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently learning to develop for the .net compact framework using c# in VS2008
I am currently using netbeans 6.7 to develop some j2me apps for a phone.
I'm currently using the iOS 5 SDK trying to develop my app. I'm trying
I currently develop an application in C# with framework .NET 3.5 SP1. In my
I'm currently trying to develop a site which queries text information. I already have
Here's my problem. I'm currently trying to develop a .Net Compact Framework 2.0 application
Currently I am using Netbeans to develop applications in Swing, but Netbeans is very
Currently, I'm trying to develop a rich internet application using Flash Builder 4 Beta
I am currently develop iphone app. the type of the app is Tab Bar.
I need some help with GUI Iphone development I am currently develop iphone application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.