I\'m trying to bind my window title to a property in my view model, like so:
Title=\"{Binding WindowTitle}\"
The property looks like this:<
That's because WPF has no way of knowing that WindowTitle
depends on CurrentProfileName
. Your class needs to implement INotifyPropertyChanged
, and when you change the value of CurrentProfileName
, you need to raise the PropertyChanged
event for CurrentProfileName
and WindowTitle
private string _currentProfileName;
public string CurrentProfileName
{
get { return __currentProfileName; }
set
{
_currentProfileName = value;
OnPropertyChanged("CurrentProfileName");
OnPropertyChanged("WindowTitle");
}
}
UPDATE
Here's a typical implementation of INotifyPropertyChanged
:
public class MyClass : INotifyPropertyChanged
{
// The event declared in the interface
public event PropertyChangedEventHandler PropertyChanged;
// Helper method to raise the event
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName);
}
...
}