I
I
iki900092017-12-10 19:59:37
WPF
iki90009, 2017-12-10 19:59:37

How to update the TextBox Text when updating the TText variable?

<TextBox  Name="TextBoxText" 
Text="{Binding Source={x:Static  local:G.TText}, Mode=OneWay}"    >
</TextBox>

public /*static*/ class G
  {
    public static string TText { get; set; }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sumor, 2017-12-10
@Sumor

Without perversions in any way, since a static field cannot be the subject of INotifyPropertyChanged and so on.
You either need to build an intermediate wrapper that supports the change notification logic, or manually notify the Binding about the change via UpdateSource.

A
Alexander Yudakov, 2017-12-11
@AlexanderYudakov

Theory:
https://msdn.microsoft.com/en-us/library/ms743643(...
Example:
https://msdn.microsoft.com/en-us/library/ms743695(...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question