WPF liaison de ne pas mettre à jour la vue

J'ai un textblock:

<TextBlock HorizontalAlignment="Left" Name="StatusText" Margin="0,20" TextWrapping="Wrap" Text="{Binding StatusText}">
            ... Status ...
</TextBlock>

le code-behind:

public StatusPage()
{
    InitializeComponent();
    this.DataContext = new StatusPageViewModel(this);
}

et dans le viewModel:

private string _statusText;
///<summary>
///Status text
///</summary>
public string StatusText
{
    get { return _statusText; }
    set { _statusText = value; }
}

et en fonction dans le viewModel:

string statusText = Status.GetStatusText();
this.StatusText = statusText;

GetStatusText() renvoie la chaîne "Travaux", etc. Les valeurs de que les fonctions sont affectés à la this.StatusText mais la propriété text de TextBlock ne changent pas et montre encore réservé "... l'État..."

Je suis au courant de ce genre de questions -->
CLIQUEZ sur<--- mais après avoir lu cela, je ne suis pas encore en mesure de trouver une solution

@Mise à jour

Après vos suggestions, j'ai mis à jour mon code et maintenant j'ai ceci:

public string StatusText
{
    get 
    {
        return _statusText;
    }
    set 
    {
        _statusText = value; 
        RaisePropertyChanged("StatusText");
    }
}

et de la déclaration de viewModel:

 public class StatusPageViewModel : ObservableObject, INavigable

où:

ObservableObject classe est:

public abstract class ObservableObject : INotifyPropertyChanged
{
    #region INotifyPropertyChanged Members

    ///<summary>
    ///Raises the PropertyChange event for the property specified
    ///</summary>
    ///<param name="propertyName">Property name to update. Is case-sensitive.</param>
    public virtual void RaisePropertyChanged(string propertyName)
    {
        OnPropertyChanged(propertyName);
    }

    ///<summary>
    ///Raised when a property on this object has a new value.
    ///</summary>
    public event PropertyChangedEventHandler PropertyChanged;

    ///<summary>
    ///Raises this object's PropertyChanged event.
    ///</summary>
    ///<param name="propertyName">The property that has a new value.</param>
    protected virtual void OnPropertyChanged(string propertyName)
    {

        PropertyChangedEventHandler handler = this.PropertyChanged;
        if (handler != null)
        {
            var e = new PropertyChangedEventArgs(propertyName);
            handler(this, e);
        }
    }

    #endregion //INotifyPropertyChanged Members
}

Mais sa ne fonctionne toujours pas

Est votre problème a été résolu?
oui
Alors, quelle est la solution? Je suis confrontée au même problème. INotifyPropertyChanged est mis en œuvre, le Mode de 1way/2ways ne fait aucune différence.

OriginalL'auteur szpic | 2014-08-27