TagElement.xaml.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using Prism.Commands;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Media;
  5. namespace SHJX.Service.Librarys.MainLibrarys
  6. {
  7. /// <summary>
  8. /// TagElement.xaml 的交互逻辑
  9. /// </summary>
  10. public partial class TagElement : UserControl
  11. {
  12. public TagElement()
  13. {
  14. InitializeComponent();
  15. }
  16. public DelegateCommand ClickCommand
  17. {
  18. get => (DelegateCommand)GetValue(ClickCommandProperty);
  19. set => SetValue(ClickCommandProperty, value);
  20. }
  21. public static readonly DependencyProperty ClickCommandProperty =
  22. DependencyProperty.Register(nameof(ClickCommand), typeof(DelegateCommand), typeof(TagElement),
  23. new UIPropertyMetadata(null, (obj, args) =>
  24. {
  25. TagElement control = obj as TagElement;
  26. Button path = control?.btn_click;
  27. path.Command = args.NewValue as DelegateCommand;
  28. }));
  29. public ImageSource DisplayImage
  30. {
  31. get => (ImageSource)GetValue(DisplayImageProperty);
  32. set => SetValue(DisplayImageProperty, value);
  33. }
  34. public static readonly DependencyProperty DisplayImageProperty =
  35. DependencyProperty.Register(nameof(DisplayImage), typeof(ImageSource), typeof(TagElement),
  36. new UIPropertyMetadata(null, (obj, args) =>
  37. {
  38. var control = obj as TagElement;
  39. var path = control?.img_display;
  40. path.Source = (ImageSource)args.NewValue;
  41. }));
  42. public string TagDetail
  43. {
  44. get => (string)GetValue(TagDetailProperty);
  45. set => SetValue(TagDetailProperty, value);
  46. }
  47. public static readonly DependencyProperty TagDetailProperty =
  48. DependencyProperty.Register(nameof(TagDetail), typeof(string), typeof(TagElement),
  49. new UIPropertyMetadata(null, (obj, args) =>
  50. {
  51. var control = obj as TagElement;
  52. var path = control?.tb_tag_detail;
  53. path.Text = (string)args.NewValue;
  54. }));
  55. public double IconSize
  56. {
  57. get => (double)GetValue(IconSizeProperty);
  58. set => SetValue(IconSizeProperty, value);
  59. }
  60. public static readonly DependencyProperty IconSizeProperty =
  61. DependencyProperty.Register(nameof(IconSize), typeof(double), typeof(TagElement),
  62. new UIPropertyMetadata(0.0, (obj, args) =>
  63. {
  64. var control = obj as TagElement;
  65. var path = control?.img_display;
  66. path.Width = (double)args.NewValue;
  67. path.Height = (double)args.NewValue;
  68. }));
  69. }
  70. }