There is a variable that gets the value calculated by the method when new data is received from the stream. How to make a programmatic text change in a textbox when assigning a new value to a variable. Software means without user interaction, button presses, etc. Do not check the timer?
1 answer
For your class, implement the INotifyPropertyChanged interface. It is required to alert you that the property value has changed. Read more about it in MSDN .
Then whenever your property changes, the interface will update and display the actual data.
If you only need to display information, it is better to use TextBlock instead of TextBox .
<TextBlock Text="{Binding НазваниеCвойства}" ... /> - INotifyPropertyChanged - as I understand it - will it avoid direct access to an object from another class? At first I decided to check if the synchronization method works at all. I did this:
MainWindow fs = (MainWindow)Application.Current.MainWindow; fs.artist.Dispatcher.BeginInvoke(new Action(delegate () { fs.artist.Content = TagInfo.artist; }));MainWindow fs = (MainWindow)Application.Current.MainWindow; fs.artist.Dispatcher.BeginInvoke(new Action(delegate () { fs.artist.Content = TagInfo.artist; }));I know that my hands would be torn off for that, for that I know what works. Be sure to rewrite as you advised)) Thank you! - Tafaube - @ Maxim, do you mean from another stream? Yes, it will allow you to perform calculations in another thread, and then, when the result is obtained, return to the UI stream. Thus, there will be no direct connection with the controls. On this site, as far as I understood, there is an opportunity to get a review of the code, so that you can create a new question and hear the opinion of other members of the community. If the answer suits you, then I think you can mark it with a green check mark. - Ev_Hyper
|