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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:32:21+00:00 2026-05-29T11:32:21+00:00

Currently in my app I use the func/lambda method of showing message boxes as

  • 0

Currently in my app I use the func/lambda method of showing message boxes as explained in the url below:

http://www.deanchalk.me.uk/post/WPF-MVVM-e28093-Simple-e28098MessageBoxShowe28099-With-Action-Func.aspx

To pass the message box text and caption is not a problem, however I also want to pass the image box image and image box type (yes/no etc). These are WPF enumerations. Currently I wrote a few methods to convert those enums into non WPF (own made) enums but it feels a bit tedious to copy every value.

Is it acceptable to use WPF enumerations in ViewModel? (I guess not). And if not, how can I prevent them to be used and still select them in the ViewModel?

  • 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-29T11:32:22+00:00Added an answer on May 29, 2026 at 11:32 am

    I’m slightly confused with your terms ModelView, and ViewModel. With MVVM, there is just the model, the view, and the view model.

    That article is talking about abstracting the message box so that you can run unit tests without blocking the build server while it waits for user interaction.

    The implementation uses the Func delegate, but you could do this just as easily using an interface. An approach then would be to create your own enumerations, and then convert them for the MessageBox implementation of the interface.

    E.g.

    public enum ConfirmationResult
    {
      Yes,
      No, 
      Cancel
      ..etc
    }
    
    public enum ConfirmationType
    {
      YesNo,
      OkCancel
      ..etc    
    }
    
    public interface IConfirmation
    {
      ConfirmationResult ShowConfirmation(string message, ConfirmationType confirmationType)
    }
    
    public class MessageBoxConfirmation : IConfirmation
    {
      ConfirmationResult ShowConfirmation(string message, ConfirmationType confirmationType)
      {
        // convert ConfirmationType into MessageBox type here
        // MessageBox.Show(...)
        // convert result to ConfirmationResult type
      }
    }
    

    Your view models would then take an IConfirmation as a dependency (in their constructor for example), and in unit tests, you can stub the IConfirmation interface to always return a particular result from the ShowConfirmation method.

    You could also overload the ShowConfirmation method to provide options for images, window titles etc.

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

Sidebar

Related Questions

I have a WinFrom App, use synchronous method to download string from a url,
I'm currently working on building a java web app. I've been looking to use
In C++ Windows app, I launch several long running child processes (currently I use
I'm currently developing an app which will use a Linq to SQL (or possibly
In our Smartclient app we currently use PostSharp to inject get/set code into auto
I am currently making an app that will control and make use of the
I'm converting an app to use fragments using the compatibility library. Now currently I
I'm converting an app to use SQL Server 2008 that is currently using SQLite.
I am currently writing an app to use system services to import an image.
I am learning log4net and currently testing out how to use App.Config for XMLConfiguration.

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.