清理ColorPicker,进度条。修复UI问题
This commit is contained in:
@@ -13,8 +13,8 @@ namespace Melskin.Controls
|
||||
/// </summary>
|
||||
public class SearchableComboBox : ComboBox
|
||||
{
|
||||
private TextBox _editableTextBox;
|
||||
private bool _isInternalOperation;
|
||||
private TextBox editableTextBox;
|
||||
private bool isInternalOperation;
|
||||
|
||||
static SearchableComboBox()
|
||||
{
|
||||
@@ -41,30 +41,30 @@ namespace Melskin.Controls
|
||||
|
||||
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
|
||||
{
|
||||
if (_isInternalOperation) return;
|
||||
if (isInternalOperation) return;
|
||||
|
||||
_isInternalOperation = true;
|
||||
isInternalOperation = true;
|
||||
base.OnSelectionChanged(e);
|
||||
|
||||
// 重点 1:选中项改变后,必须彻底清空过滤器,否则下次打开下拉框只剩下一项
|
||||
this.Items.Filter = null;
|
||||
_isInternalOperation = false;
|
||||
isInternalOperation = false;
|
||||
}
|
||||
|
||||
private void OnEditableTextBoxTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (_isInternalOperation) return;
|
||||
if (isInternalOperation) return;
|
||||
|
||||
string searchText = _editableTextBox.Text;
|
||||
string searchText = editableTextBox.Text;
|
||||
string selectedText = GetItemDisplayText(SelectedItem);
|
||||
|
||||
// 重点 2:断开锁定逻辑
|
||||
// 如果文本框的内容和当前选中项的文本不一致,说明用户正在打字替换内容
|
||||
if (SelectedItem != null && searchText != selectedText)
|
||||
{
|
||||
_isInternalOperation = true;
|
||||
isInternalOperation = true;
|
||||
SelectedItem = null; // 必须将 SelectedItem 设为 null,否则 WPF 会强行还原文本
|
||||
_isInternalOperation = false;
|
||||
isInternalOperation = false;
|
||||
}
|
||||
|
||||
// 重点 3:执行过滤
|
||||
@@ -79,7 +79,7 @@ namespace Melskin.Controls
|
||||
};
|
||||
|
||||
// 自动打开下拉框
|
||||
if (!IsDropDownOpen && _editableTextBox.IsFocused && !string.IsNullOrEmpty(searchText))
|
||||
if (!IsDropDownOpen && editableTextBox.IsFocused && !string.IsNullOrEmpty(searchText))
|
||||
{
|
||||
IsDropDownOpen = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user