BookmarkContent.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using PDF_Office.Helper;
  2. using PDF_Office.ViewModels.BOTA;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace PDF_Office.Views.BOTA
  18. {
  19. /// <summary>
  20. /// BookmarkContent.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class BookmarkContent : UserControl
  23. {
  24. public BookmarkContent()
  25. {
  26. InitializeComponent();
  27. }
  28. private void TxtTitleInput_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  29. {
  30. if (sender is TextBox && IsLoaded)
  31. {
  32. TextBox textBox = sender as TextBox;
  33. if (textBox.Visibility == Visibility.Visible)
  34. {
  35. textBox.Focus();
  36. }
  37. }
  38. }
  39. private void ListViewItem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  40. {
  41. var vm = this.DataContext as BookmarkContentViewModel;
  42. object[] objects = new object[] { sender, e };
  43. vm.ListViewItemMouseDownCommand.Execute(objects);
  44. }
  45. private void ListViewItem_LostFocus(object sender, RoutedEventArgs e)
  46. {
  47. ListBoxItem listItem = sender as ListBoxItem;
  48. if (listItem != null)
  49. {
  50. TextBox textBox = CommonHelper.FindVisualChild<TextBox>(listItem);
  51. if (textBox.Visibility != Visibility.Visible)
  52. listItem.IsSelected = false;
  53. }
  54. }
  55. }
  56. }