fork download
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Input;
  4.  
  5. namespace WpfLib.Behaviors
  6. {
  7. public class UIElementHelper
  8. {
  9. public static ICommand GetMouseDownCommand(DependencyObject obj)
  10. {
  11. return (ICommand)obj.GetValue(MouseDownCommandProperty);
  12. }
  13.  
  14. public static void SetMouseDownCommand(DependencyObject obj, ICommand value)
  15. {
  16. obj.SetValue(MouseDownCommandProperty, value);
  17. }
  18.  
  19. // Using a DependencyProperty as the backing store for MouseDownCommand. This enables animation, styling, binding, etc...
  20. public static readonly DependencyProperty MouseDownCommandProperty =
  21. DependencyProperty.RegisterAttached("MouseDownCommand", typeof(ICommand), typeof(UIElementHelper), new PropertyMetadata(null, PropertyChanged));
  22. public static void PropertyChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
  23. {
  24. var cmd = e.NewValue as ICommand;
  25. if (cmd != null)
  26. {
  27. var element = s as UIElement;
  28. element.MouseDown += (sender, ex) =>
  29. {
  30. cmd.Execute(ex);
  31. };
  32. }
  33. }
  34. }
  35. }
  36.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(9,52): error CS0246: The type or namespace name `DependencyObject' could not be found. Are you missing an assembly reference?
prog.cs(14,48): error CS0246: The type or namespace name `DependencyObject' could not be found. Are you missing an assembly reference?
prog.cs(20,32): error CS0246: The type or namespace name `DependencyProperty' could not be found. Are you missing an assembly reference?
prog.cs(22,44): error CS0246: The type or namespace name `DependencyObject' could not be found. Are you missing an assembly reference?
prog.cs(22,64): error CS0246: The type or namespace name `DependencyPropertyChangedEventArgs' could not be found. Are you missing an assembly reference?
Compilation failed: 5 error(s), 0 warnings
stdout
Standard output is empty