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 267159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:30:18+00:00 2026-05-11T23:30:18+00:00

I like the MVVM idea of a RelayCommand that’s exposed by the ViewModel. That’s

  • 0

I like the MVVM idea of a RelayCommand that’s exposed by the ViewModel. That’s nice and elegant, for operations that can be done with no further user input. Simple. Testable.

However, not all operations are UI-less. Some require confirmation (“Are you sure you want to delete?”). Others require more information yet. Opening a file might entail anything from a File Open dialog up through a full-blown Import wizard.

What’s the best way, within an MVVM app, to write commands that require user input? Is there an established pattern for solving this with dependency injection somehow? Should I write a KeyDown handler in the code-behind, and have it explicitly execute the event? Should I fall back on RoutedUICommand, and put all the “display the next GUI” code in my View? Or is there something obvious that I’m totally missing?

  • 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-05-11T23:30:19+00:00Added an answer on May 11, 2026 at 11:30 pm

    I usually use Dependency Injection to inject some kind of abstract IShowTheInterface thing, and then invoke methods on the abstraction from within the Command. These methods should then give you the answers you need to determine whether to continue with the action at all, and what input the user gave.

    I recently used this as an example in a blog post with a bit of a different topic.

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

Sidebar

Related Questions

I wonder if I can create a RelayCommand on my ViewModel like this: public
I'm working with MVVM Light Toolkit, and I'd like to create a RelayCommand .
I'm developing WPF applications using MVVM pattern. I have ViewModel with code like this:
I'm trying to implement a WPF application using MVVM (Model-View-ViewModel) pattern and I'd like
I've an MVVM-lite application that I'd like to have unit testable. The model uses
I have a simple WPF application where I don't have any mvvm framework like
I would like to use an MVVM in a WPF project I'm working on,
Ok I really would like to know how expert MVVM developers handle an openfile
I need to have a command handler for a ToggleButton that can take multiple
Silverlight FX looks like it will cover my MVVM needs, however I'm struggling to

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.