Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind variable to textblock

Tags:

c#

wpf

xaml

Context :

I have a wpf window that has a variable float processTime = -1;.

This variable is passed by reference to a user control. The user control then pass the reference of the variable to a COM. The COM increments the variable.

If I put a breakpoint in my window, I can see the new variable value.

Now, I want to display it on screen.

Problem :

As far as I know, you can't bind a variable to a wpf textblock. You must use a property.

Also, I can't pass a property by ref to my function. That's precisely why I'm using a variable.

EDIT : Note that the COM job is to stream a video with directshow filters. Which means the job is not just done after the call... It's running for a long time, thus why I want to bind a variable to screen so you can see the values, live.

Cheap solution

I could do some kind of timer that updates a textblock value every second...

like image 653
Dave Avatar asked Jul 27 '26 15:07

Dave


1 Answers

 public float ProcessTime
 {
    get {return _processTime;}
 }


 //after you do your COM stuff call
 this.OnPropertyChanged("ProcessTime"); 
like image 153
blindmeis Avatar answered Jul 30 '26 06:07

blindmeis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!