code_junkie

Dependency Properties with Explicit Interfaces

Nov 13th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. interface MyInterface : INotifyPropertyChanged
  2. {
  3. string Text { get; set; }
  4. }
  5.  
  6. class MyViewModel : MyInterface
  7. {
  8. private string text;
  9. public string Text
  10. {
  11. get { return text; }
  12. set
  13. {
  14. if (text != value)
  15. {
  16. text = value;
  17. // TODO: Raise the NotifyPropertyChanged event here
  18. }
  19. }
  20. }
  21. }
  22.  
  23. interface IViewModel
  24. {
  25. string Text { get; set; }
  26. }
  27.  
  28. public static readonly DependencyProperty TextProperty =
  29. DependencyProperty.Register("Text",
  30. typeof(string), typeof(IViewModel));
  31.  
  32. public static readonly DependencyProperty TextProperty =
  33. DependencyProperty.Register("Text",
  34. typeof(string), typeof(ImplementingClass));
Add Comment
Please, Sign In to add comment