回答編集履歴
1
文字入力時の挙動がおかしかったので、リストから選択したときのみ処理が走るように修正。
test
CHANGED
@@ -76,39 +76,67 @@
|
|
76
76
|
|
77
77
|
{
|
78
78
|
|
79
|
-
|
79
|
+
if (sender is ComboBox combo
|
80
80
|
|
81
|
+
&& combo.Template.FindName("PART_EditableTextBox", combo) is TextBox textbox
|
82
|
+
|
81
|
-
|
83
|
+
&& textbox != null)
|
82
84
|
|
83
85
|
{
|
84
86
|
|
85
|
-
var
|
87
|
+
SelectionChangedEventHandler combo_selectionchanged = null;
|
86
88
|
|
89
|
+
RoutedEventHandler textbox_selectionchanged = null;
|
90
|
+
|
91
|
+
RoutedEventHandler combo_unloaded = null;
|
92
|
+
|
93
|
+
|
94
|
+
|
87
|
-
|
95
|
+
textbox_selectionchanged = (s2, e2) =>
|
88
96
|
|
89
97
|
{
|
90
98
|
|
91
|
-
textbox.Selection
|
99
|
+
if (textbox.SelectionLength != 0)
|
92
100
|
|
93
|
-
|
101
|
+
{
|
94
102
|
|
95
|
-
|
103
|
+
textbox.SelectionChanged -= textbox_selectionchanged;
|
96
104
|
|
105
|
+
textbox.Select(0, 0);
|
106
|
+
|
97
|
-
}
|
107
|
+
}
|
108
|
+
|
109
|
+
};
|
98
110
|
|
99
111
|
|
100
112
|
|
101
|
-
|
113
|
+
combo_selectionchanged = (s1, e1) =>
|
102
114
|
|
103
|
-
{
|
115
|
+
{
|
104
116
|
|
105
|
-
|
117
|
+
if (combo.IsDropDownOpen)
|
106
118
|
|
107
|
-
|
119
|
+
textbox.SelectionChanged += textbox_selectionchanged;
|
108
120
|
|
109
|
-
|
121
|
+
};
|
110
122
|
|
123
|
+
|
124
|
+
|
125
|
+
combo_unloaded = (s3, e3) =>
|
126
|
+
|
127
|
+
{
|
128
|
+
|
111
|
-
|
129
|
+
combo.SelectionChanged -= combo_selectionchanged;
|
130
|
+
|
131
|
+
combo.Unloaded -= combo_unloaded;
|
132
|
+
|
133
|
+
};
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
combo.SelectionChanged += combo_selectionchanged;
|
138
|
+
|
139
|
+
combo.Unloaded += combo_unloaded;
|
112
140
|
|
113
141
|
}
|
114
142
|
|