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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:57:26+00:00 2026-06-01T08:57:26+00:00

Working with a WPF application. I am very much wonderin if it is possible

  • 0

Working with a WPF application.
I am very much wonderin if it is possible to get a function luke the examle below into a class function (im not yet very experianced with C#).

private void counter01_Tick(object sender, EventArgs e)
{
    if (counter01Ticks > 0)
    {
        //subtract 1 each time
        counter01Ticks--;

        //subtrack 1 secon each time
        counter01Span = counter01Span.Subtract(TimeSpan.FromSeconds(1));

        //update the progressbar
        progBar01.Value++;

        //get the % to show 
        progBar01Text.Text = Convert.ToString(Math.Round(((progBar01.Value / progBar01.Maximum) * 100), 0)) + "%";

        //Label1 will show the count down.
        string countDown = counter01Span.ToString();
        TimeRemain01.Content = countDown;
    }
    else
    {
        counter01.Stop();
        resetCounter01();

        WarningMessage msgWarnOne = new WarningMessage();
        msgWarnOne.warnMessage.Text = Properties.Settings.Default.msgScout01;
        msgWarnOne.ShowDialog();  
    }
}

It is just a part of a counter. but i want to add more counters to my application later on.
Therefore i marked all the parameters with a number (01) in my code.

So what i do not want to do, i copy-paste the code and change the number for every counter, but rather have the number as a input number or something.

Would that be possible?
if i9 would understand it for this small part of code, i think i will be able to do it with the other parts too (above is only the tick form a counter).

@Users that user the answer below:
http://www.c-sharpcorner.com/uploadfile/mahesh/user-control-in-wpf/
Has helped me understand it better and migh be usefull to read too.

  • 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-01T08:57:28+00:00Added an answer on June 1, 2026 at 8:57 am

    Yes you can put all of this (together with your XAML declaration) into a WPF-user control and put multiple of these into other Windows/Controls/…

    Just look at the tutorial I linked in – should explain everything you need.

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

Sidebar

Related Questions

I am working on a WPF MVVM application. It has a custom canvas class
I am working on a WPF application with MVVM, but am not using any
I am working on a WPF/Prism 4/AvalonDoc application. One of my views is very
I'm working on a WPF application, and I'm structuring it using the MVVM pattern.
I'm working on a WPF application which should be utilizable with two monitors. In
I am working on a wpf application. Here I need to use System.Windows.Forms.FolderBrowserDialog in
I'm working on a WPF application that contains a wrapper UI that is actually
I'm recently working on a WPF application that uses the datagrid from the WPF
I'm building a WPF application and working with the MVVM pattern. I have 4
I'm working on a WPF MVVM application and I've got a TextBox on my

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.