Last active
December 17, 2015 19:09
-
-
Save oliverw/5658814 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FooViewModel : ReactiveObject | |
{ | |
DateTime dueDate; | |
public DateTime DueDate | |
{ | |
get { return dueDate; } | |
set { this.RaiseAndSetIfChanged(ref dueDate, value); } | |
} | |
} | |
public class DueDateConverter : IBindingTypeConverter | |
{ | |
#region IBindingTypeConverter implementation | |
public int GetAffinityForObjects(Type lhs, Type rhs) | |
{ | |
// Too bad, I will never be called | |
throw new NotImplementedException(); | |
} | |
public bool TryConvert(object from, Type toType, object conversionHint, out object result) | |
{ | |
var dt = (DateTime)from; | |
return dt < DateTime.UtcNow ? "Date lies in the past" : "Date lies in the future"; | |
} | |
#endregion | |
} | |
this.OneWayBind(ViewModel, (x)=> x.DueDate, (view)=> view.DueDateLabel.Text, null, new DueDateConverter()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment