PicUserControl.xaml.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using ivf_tl_CustomControls;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace ivf_tl_Manage.UserControls
  17. {
  18. /// <summary>
  19. /// PicUserControl.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class PicUserControl : UserControl
  22. {
  23. public event Action<PicUserControl, bool> SelectedPropertyChangedEevent;
  24. public PicUserControl()
  25. {
  26. InitializeComponent();
  27. }
  28. public int SelectedNum
  29. {
  30. get { return (int)GetValue(SelectedNumProperty); }
  31. set { SetValue(SelectedNumProperty, value); }
  32. }
  33. public static readonly DependencyProperty SelectedNumProperty =
  34. DependencyProperty.Register("SelectedNum", typeof(int), typeof(PicUserControl), new PropertyMetadata(1));
  35. public string ImageInfoString
  36. {
  37. get { return (string)GetValue(ImageInfoStringProperty); }
  38. set { SetValue(ImageInfoStringProperty, value); }
  39. }
  40. public static readonly DependencyProperty ImageInfoStringProperty =
  41. DependencyProperty.Register("ImageInfoString", typeof(string), typeof(PicUserControl), new PropertyMetadata(null));
  42. public ImageSource ImageSourceUrl
  43. {
  44. get { return (ImageSource)GetValue(ImageSourceUrlProperty); }
  45. set { SetValue(ImageSourceUrlProperty, value); }
  46. }
  47. public static readonly DependencyProperty ImageSourceUrlProperty =
  48. DependencyProperty.Register("ImageSourceUrl", typeof(ImageSource), typeof(PicUserControl), new PropertyMetadata(null));
  49. public bool IsSelected
  50. {
  51. get { return (bool)GetValue(IsSelectedProperty); }
  52. set { SetValue(IsSelectedProperty, value); }
  53. }
  54. // Using a DependencyProperty as the backing store for IsSelected. This enables animation, styling, binding, etc...
  55. public static readonly DependencyProperty IsSelectedProperty =
  56. DependencyProperty.Register("IsSelected", typeof(bool), typeof(PicUserControl), new PropertyMetadata(false, new PropertyChangedCallback(IsSelectedPropertyChangedCallback)));
  57. private static void IsSelectedPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  58. {
  59. if (!(d is PicUserControl source)) return;
  60. if (!(e.NewValue is bool newValue)) return;
  61. source.SelectedPropertyChangedEevent?.Invoke(source, newValue);
  62. }
  63. }
  64. }