-2

I want to display the string _lunedi in a textbox, the string _lunedi is updated periodically using InitializeBoxes().

I have my class:

public event PropertyChangedEventHandler PropertyChanged;
private string _lunedi= "lunedi ";
    public string lunedi
    {
        get { return this._lunedi; }

        set
        {
            if (value != this._lunedi)
            {
                this._lunedi = value;
                NotifyPropertyChanged("lunedi");
            }
        }
    }


    public void NotifyPropertyChanged(string propertyName)
    {
        if (this.PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

whit this method change the lunedi:

private void InitializeBoxes()
    {
        lunedi += todayPivot.Day;
    }

xaml:

<Border>
    <TextBlock Text="{Binding Path=lunedi, UpdateSourceTrigger=PropertyChanged}"></TextBlock>
</Border>

The problem is that the text of the textblock is empty. Thank you.

Pylyp Lebediev
  • 1,991
  • 4
  • 26
  • 44
Andrea485
  • 527
  • 2
  • 6
  • 16

1 Answers1

0

Sounds like the binding is using one time try this instead

<Border>
<TextBlock Text="{Binding Path=lunedi, Mode=OneWay}"></TextBlock>

Ken Tucker
  • 4,126
  • 1
  • 18
  • 24