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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:01:49+00:00 2026-06-01T02:01:49+00:00

I have the following dependency property that works fine but it does not auto

  • 0

I have the following dependency property that works fine but it does not auto update.
The dependency properties are all properties of the RegistrationButton.cls class.

public static readonly DependencyProperty DuurStilstandProperty =
        DependencyProperty.Register("DuurStilstand", typeof(string), typeof(RegistrationButton), new UIPropertyMetadata(""));

.NET Wrapper public property:

 public string DuurStilstand
    {
        get { return (string)GetValue(DuurStilstandProperty); }
        set { SetValue(DuurStilstandProperty, value); }
    }

What i am basically doing is trying to display a time (DateTime with default 3 min) and after that the time keeps increasing by using a timer and increments the Datetime by 1 second every second.

So on the screen it should display 00:03:00 and starts incrementing every second.

I have tried TwoWay binding (not sure if this is the issue?) but when i try the following my application crashes:

public static readonly DependencyProperty DuurStilstandProperty =
       DependencyProperty.Register("DuurStilstand", typeof(string), typeof(RegistrationButton), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));

The code that involved creating the button (where the time is being displayed) and the timer:

public void InitializeDispatcherTimerStilstand()
    {
        timerStilstand = new DispatcherTimer();
        timerStilstand.Tick += new EventHandler(timerStilstand_Tick);
        timerStilstand.Interval = new TimeSpan(0, 0, 1);
        timerStilstand.Start();
        timerStilstand.ToString();
    }

    private void timerStilstand_Tick(object sender, EventArgs e)
    {
        this.tijdStilStandRegistrationBtn.AddSeconds(1);
    }

Code that creates the button:

Btn.Duurstilstand is the property that holds the time (hh:mm:ss format).

tijdStilStandRegistrationBtn = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 3, 0); 

        RegistrationButton btn = new RegistrationButton(GlobalObservableCollection.regBtns.Count.ToString());
        btn.RegistrationCount = GlobalObservableCollection.regBtnCount;
        btn.Title = "btnRegistration" + GlobalObservableCollection.regBtnCount;
        btn.BeginStilstand = btn.Time;
        btn.DuurStilstand = String.Format("{0:T}", this.tijdStilStandRegistrationBtn);

        GlobalObservableCollection.regBtns.Add(btn);
        GlobalObservableCollection.regBtnCount++;

        InitializeDispatcherTimerStilstand();   

Currently it only seems to display 00:03:00 as time but it does not update when my program is running.

I also tried setting the UpDateSourceTrigger to PropertyChanged but it made no difference (this is located in a Style of type RegistrationButton).

<TextBlock x:Name="tbDuurStilstand" TextWrapping="Wrap" 
                                   Text="{Binding DuurStilstand, UpdateSourceTrigger=PropertyChanged}" 
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center" 
                                   Margin="7.5,5,0,0" Height="24.8266666666667"/>

EDIT

public void CreateRegistrationButton()
    {
        tijdStilStandRegistrationBtn = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 3, 0); 

        RegistrationButton btn = new RegistrationButton(GlobalObservableCollection.regBtns.Count.ToString());
        btn.RegistrationCount = GlobalObservableCollection.regBtnCount;
        btn.Title = "btnRegistration" + GlobalObservableCollection.regBtnCount;
        btn.BeginStilstand = btn.Time;
        //btn.DuurStilstand = String.Format("{0:T}", this.tijdStilStandRegistrationBtn);

        GlobalObservableCollection.regBtns.Add(btn);
        GlobalObservableCollection.regBtnCount++;

        InitializeDispatcherTimerStilstand(btn);     
    }

EDIT 2:

timerStilstand.Tick += () => timerStilstand_Tick(btn); //error at ()

“Delegate ‘System.EventHandler’ does not take 0 arguments”

Kind Regards.

  • 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-01T02:01:51+00:00Added an answer on June 1, 2026 at 2:01 am

    DateTime is an immutable struct. You have to catch the result.
    I think you need:

    private void timerStilstand_Tick(object sender, EventArgs e)
    {
        this.tijdStilStandRegistrationBtn = 
            this.tijdStilStandRegistrationBtn.AddSeconds(1);
    
        btn.DuurStilstand = 
            String.Format("{0:T}", this.tijdStilStandRegistrationBtn);
    
    }
    

    Take 2

    public void InitializeDispatcherTimerStilstand(RegistrationButton btn)
    {
        timerStilstand = new DispatcherTimer();
        //timerStilstand.Tick += new EventHandler(timerStilstand_Tick);
        timerStilstand.Tick += (aa, bb) => timerStilstand_Tick(btn);   // use capturing to pass btn
    
        timerStilstand.Interval = new TimeSpan(0, 0, 1);
        timerStilstand.Start();
        //timerStilstand.ToString();
    }
    
    private void timerStilstand_Tick(RegistrationButton btn)
    {
       this.tijdStilStandRegistrationBtn = 
            this.tijdStilStandRegistrationBtn.AddSeconds(1);
    
        btn.DuurStilstand = 
            String.Format("{0:T}", this.tijdStilStandRegistrationBtn);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some simple Dependency Properties that are not working. I've looked over them,
I have the following dependency property in my MainWindow class (inherits from WPF's Window)
I have the following dependency property inside a class: class FooHolder { public static
I'm on a roll today... I have the following code delaring a dependency property
I have the following ViewModel-Property: public List<List<string>> Names .... //It's a dependency property In
I have a custom property that works perfectly, except when it's bound to an
I have a UserControl that I've added a Dependency Property to: public partial class
I have following class that defines attached property to set children's margin: public class
I have the following 'circular dependency' in my Inner Join, any ideas how to
Assume that I have a .NET Workflow Foundation (WF) SequenceActivity class with the following

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.