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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:56:49+00:00 2026-06-06T08:56:49+00:00

I am implementing a little extension for an existing application. Now I am creating

  • 0

I am implementing a little extension for an existing application. Now I am creating a ‘wpf-library’ with mvvm and everything seems quite nice at the moment.

Now let’s say I have an event to delete some datasets from the underlying Database. I don’t want to do this in my extension-app but in the calling-application.

So what I have achieved (and whats working) is that the user clicks on my ‘remove’ button, the view-model implemented the command and here I am able to fire an event. What I wanted is to send the event out to the calling-application.

My startup-class that the calling-app is able to see now like this:

    public UserControl ViewToShowInContainer { get; private set; }

    public StartMyExtensionApplication(Model.TransportClass dataToWorkWith)
    {
        ViewToShowInContainer = new View.MainView();
        (ViewToShowInContainer.DataContext as VehicleSearchWPF.ViewModel.MyMainViewModel).RemoveSelectStatementFromDB += new EventHandler<SelectStatementRemovedEventArgs>(StartVehicleSearch_RemoveSelectStatementFromDB);
        LocalDataToWorkWith.MapTransportClass(dataToWorkWith);
    }

    void StartVehicleSearch_RemoveSelectStatementFromDB(object sender, SelectStatementRemovedEventArgs e)
    {
        throw new NotImplementedException();
    }

But in my opinien there must be some nicer / cleaner / better method to implement this?

Thanks in advance! 🙂

  • 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-06T08:56:50+00:00Added an answer on June 6, 2026 at 8:56 am

    This indeed doesn’t seem like the right place to use normal events; a couple of other options:

    -do not use events but use ‘services’, imo more clear and more direct while still decoupling. Has the benefit that you can easily test your viewmodel (eg test that executing the Remove command effectively calls Remove on the database) by mocking the database service.

      //a database interface
    public interface IDataBase
    {
      public void Remove( string entry );
      //etc
    }
    
      //a concrete database
    public class SqlDataBase : IDataBase
    {
      //implementation of IDataBase
    }
    
      //vm uses an IDataBase
    class VehicleSearchViewModel
    {
      public VehicleSearchViewModel( IDataBase dataBase );
    
      private void Remove( string id )
      {
        dataBase.Remove( id );
      }
    }
    
      //so main app can pass it
    public StartMyExtensionApplication( .... )
    {
      var dataBase = CreateDataBase( .... );
      view.DataContext = new VehicleSearchViewModel( dataBase );
    }
    

    -use something like Prism’s IEventAggregator

    class VehicleSearchViewModel
    {
      public VehicleSearchViewModel( IEventAggregator aggr );
    
      private void Remove( string id )
      {
        aggr.Publish( new RemoveFromDBEvent{ id = id } );
      }
    }
    
    public StartMyExtensionApplication( .... )
    {
      aggr.Subscribe<RemoveFromDBEvent>( DoRemove );
    }
    
    private void DoRemove( RemoveFromDBEvent evt )
    {
      dataBase.Remove( evt.id );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a little chat application where I receive messages from a server, which
I'm currently writing a little C# library to simplify implementing little physical simulations/experiments. The
I am implementing little monitoring application, so i am hooking CreateWindowExA/W in process, so
I'm implementing a little web application using Java and the Wicket framework. Each user
I am implementing a little Black Jack game in C# and I have the
I'm busy introducing myself to jQuery by implementing a little system where onmouseover on
A little backstory, currently I'm working on implementing a triangle rendering system in Expression2
I'm currently implementing a non-renewable in-app purchase and am a little concerned over the
I'm implementing a interpreter-like project for which I need a strange little scheduling queue.
I'm implementing a REST API using ASP.NET MVC, and a little stumbling block has

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.