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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:29:51+00:00 2026-06-04T23:29:51+00:00

Im migrating an application from Windows Forms to WPF, so I am trying to

  • 0

Im migrating an application from Windows Forms to WPF, so I am trying to use the MVVM pattern, but it is getting a bit tricky to me.

In Windows forms I have a form which contains a progressBar which has defined some new methods that allow me to perform steps, set its value, etc. This code is placed in the progressBar’s code behind as below:

public class MyProgressBar : ProgressBar
{
    public MyProgressBar ()
    {
        InitializeComponent();
    }

    public void Method01()
    {...}

    public void Method02()
    {...}

    public void Method03()
    {...}
}

The code of the Method01, Method02 and Method03 is used in the container form, so, here is my question: In WPF, since I use the MVVM pattern, Where do I have to place that code??

Until now I have this classes:

My model:

public class MyFormModel : DataTable
{
    public OutputResultsDataTable()
        : base()
    {
        Columns.Add(new DataColumn("Number"));
        Columns.Add(new DataColumn("Message"));
        Columns.Add(new DataColumn("Detail"));
    }
}

My ViewModel:

public class MyNewWPFForm
{
    /// <summary>
    /// 
    /// </summary>
    public MyFormModel MyData{ get; set; }

    /// <summary>
    /// Constructor
    /// </summary>
    public MyNewWPFForm()
    {
        if (System.Windows.Application.Current.MainWindow != null)
        {
            MyData= new MyFormModel ();                
        }
    }
}

In WPF I have already created my new progressBar control and its container form, even I have been reading about MVVM but I cant understand where do I have to put the code of the Method0X, because, according to what I have read, I would have to put that code in the viewModel, but, here is another problem: How could I have access to my progress bar from my view model since it is inside another form??

Hope someone can help me. 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-04T23:29:52+00:00Added an answer on June 4, 2026 at 11:29 pm

    It sounds like the methods on your control are used for setting state of your control. You could use dependency properties to do this.

    You use binding to connect your view to your view model.

    Create a property for your controls progress.

    Then in Xaml add a binding

    <MyProgressBar Progress="{Binding CurrentProgress}" />
    

    Set the data context of your view to a new view model.
    CurrentProgress is a property on the view model.
    Implement INotifyPropertyChanged on your view model.

    For adding and removing things to/from your control you might ObservableCollection.

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

Sidebar

Related Questions

I'm in the process of migrating portions of an application from Windows Forms to
I am migrating an application from ASP.NET Web Forms to ASP.NET MVC 3. One
we are migrating our desktop to windows 7, 64 bit (from 32bit Windows XP).
I'm currently migrating an application from GMaps V2 to V3. As I use OSM
I have an application which I am in the process of migrating to Windows
I have an application that I'm migrating from flex 3 to flex 4.5. In
I'm migrating my application from Rails 3.0.12 to 3.2. I use the active_record_store to
Background: Migrating an application from ball of mud to MVC. Many classes contain HTML
I'm currently working on migrating an application from MS-Access to MS SQL Server. In
Migrating a legacy application from WebSphere v.6 to WebSphere v.8. The application's web.xml only

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.