I have a TextBox bound to a ViewModel's Text property with the following setup:
Xaml
<TextBox Text="{Binding Text}"/>
C#
public class ViewModel : INotifyPropertyChanged
{
public string Text
{
get
{
return m_Text;
}
set
{
if (String.Equals(m_Text, value))
{
return;
}
m_Text = value.ToLower();
RaisePropertyChanged("Text");
}
}
// Snip
}
When I type some stuff in to the TextBox it successfully sets the Text property on the ViewModel. The problem is that WPF ignores the property changed event that is raised by it's own update. This results in the user not seeing the text they typed converted to lowercase.
How can I change this behaviour so that the TextBox updates with lowercase text?
Note: this is just an example I have used to illustrate the problem of WPF ignoring events. I'm not really interested in converting strings to lowercase or any issues with String.Equals(string, string).