Reputation: 229
I have a property in a ViewModel called Message, a textbox is bound to it in TwoWay. How can I remove white spaces from the end of whatever string of text is bound to it.
private string message;
public string Message
{
get
{
return message;
}
set
{
SetProperty(ref message, value);
}
}
My set Property is defined like this
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] String propertyName = null)
{
if (object.Equals(storage, value)) return false;
storage = value;
this.OnPropertyChanged(propertyName);
return true;
}
Upvotes: 0
Views: 103
Reputation: 1499
You want the TrimEnd method.
private string message;
public string Message
{
get
{
return message;
}
set
{
SetProperty(ref message, value.TrimEnd());
}
https://msdn.microsoft.com/en-us/library/system.string.trimend(v=vs.110).aspx
Upvotes: 2