WritableComboBox.xaml.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  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 PDF_Office.CustomControl
  17. {
  18. /// <summary>
  19. /// WritableComboBox.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class WritableComboBox : UserControl
  22. {
  23. public WritableComboBox()
  24. {
  25. InitializeComponent();
  26. }
  27. private void writableComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  28. {
  29. if (this.writableComboBox.SelectedIndex == this.writableComboBox.Items.Count - 1)
  30. {
  31. this.writableTextBox.Width = this.writableComboBox.ActualWidth - 18;
  32. Trace.WriteLine(this.writableComboBox.ActualWidth);
  33. this.writableTextBox.Visibility = Visibility.Visible;
  34. <<<<<<< Updated upstream
  35. }
  36. else
  37. {
  38. if (this.writableTextBox != null) {
  39. this.writableTextBox.Visibility = Visibility.Hidden;
  40. }
  41. this.SelectedIndex=this.writableComboBox.SelectedIndex.ToString();
  42. =======
  43. }
  44. else
  45. {
  46. if (this.writableTextBox != null)
  47. {
  48. this.writableTextBox.Visibility = Visibility.Collapsed;
  49. }
  50. >>>>>>> Stashed changes
  51. }
  52. this.SelectedIndex = this.writableComboBox.SelectedIndex.ToString();
  53. }
  54. public string SelectedIndex
  55. {
  56. get { return (string)GetValue(SelectedIndexProperty); }
  57. set { SetValue(SelectedIndexProperty, value); }
  58. }
  59. // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
  60. public static readonly DependencyProperty SelectedIndexProperty =
  61. DependencyProperty.Register("SelectedIndex", typeof(string), typeof(WritableComboBox), new PropertyMetadata(""));
  62. public string Text
  63. {
  64. get { return (string)GetValue(TextProperty); }
  65. set { SetValue(TextProperty, value); }
  66. }
  67. // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
  68. public static readonly DependencyProperty TextProperty =
  69. <<<<<<< Updated upstream
  70. DependencyProperty.Register("Text", typeof(string), typeof(WritableComboBox), new PropertyMetadata(""));
  71. private void writableTextBox_TextChange(object sender, TextChangedEventArgs e)
  72. {
  73. if (this.writableComboBox.SelectedIndex == this.writableComboBox.Items.Count - 1)
  74. {
  75. Text = this.writableTextBox.Text;
  76. }
  77. else { Text = ""; }
  78. }
  79. =======
  80. DependencyProperty.Register("Text", typeof(string), typeof(WritableComboBox), new PropertyMetadata(""));
  81. private void writableTextBox_TextChange(object sender, TextChangedEventArgs e)
  82. {
  83. if (this.writableComboBox.SelectedIndex == this.writableComboBox.Items.Count - 1)
  84. {
  85. Text = this.writableTextBox.Text;
  86. }
  87. else { Text = ""; }
  88. }
  89. >>>>>>> Stashed changes
  90. }
  91. }