Bind a variable to a text block

Context:

I have a wpf window with a variable float processTime = -1;

.

This variable is passed by reference to the custom control. The custom element then passes the variable reference to COM. COM increments this variable.

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

Now I want to display it on the screen.

Problem:

As far as I know, you cannot bind a variable to a wpf textblock. You have to use the property.

Also, I cannot pass the property by reference to my function. This is why I am using a variable.

EDIT: Please note that the COM job is streaming video with live filters. This means that the job is not only executed after the call ... It runs for a long time, so I want to bind the variable to the screen so you can see the values ​​live.

Cheap solution

I could make some kind of timer that updates the textblock value every second ...

+3


source to share


1 answer


 public float ProcessTime
 {
    get {return _processTime;}
 }


 //after you do your COM stuff call
 this.OnPropertyChanged("ProcessTime"); 

      



+3


source







All Articles