DamageRecordControl.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Input;
  6. namespace SWRIS.Controls
  7. {
  8. /// <summary>
  9. /// RecordControl.xaml 的交互逻辑
  10. /// </summary>
  11. public partial class DamageRecordControl : UserControl
  12. {
  13. public DamageRecordControl()
  14. {
  15. InitializeComponent();
  16. }
  17. public static readonly DependencyProperty RecordsProperty =
  18. DependencyProperty.Register("Records", typeof(IEnumerable), typeof(DamageRecordControl),
  19. new PropertyMetadata(null));
  20. public static readonly DependencyProperty TitleProperty =
  21. DependencyProperty.Register("Title", typeof(string), typeof(DamageRecordControl),
  22. new PropertyMetadata("检测信息"));
  23. public IEnumerable Records
  24. {
  25. get => (IEnumerable)GetValue(RecordsProperty);
  26. set => SetValue(RecordsProperty, value);
  27. }
  28. public string Title
  29. {
  30. get => (string)GetValue(TitleProperty);
  31. set => SetValue(TitleProperty, value);
  32. }
  33. private void Record_MouseDown(object sender, MouseButtonEventArgs e)
  34. {
  35. if (e.ClickCount == 2)
  36. {
  37. if (sender is StackPanel panel && int.TryParse(panel.Tag?.ToString(), out int recordId))
  38. {
  39. (Application.Current.MainWindow as MainWindow).NavigatePage(new Uri($"Pages/DamagesPage.xaml?id=" + recordId, uriKind: UriKind.Relative));
  40. }
  41. }
  42. }
  43. }
  44. }