优化空引用
This commit is contained in:
@@ -31,8 +31,7 @@ namespace Melskin.Controls
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
_editableTextBox = GetTemplateChild("PART_EditableTextBox") as TextBox;
|
||||
if (_editableTextBox != null)
|
||||
if (GetTemplateChild("PART_EditableTextBox") is TextBox _editableTextBox)
|
||||
{
|
||||
_editableTextBox.TextChanged += OnEditableTextBoxTextChanged;
|
||||
// 点击时全选
|
||||
@@ -100,7 +99,7 @@ namespace Melskin.Controls
|
||||
var prop = item.GetType().GetProperty(path);
|
||||
if (prop != null) return prop.GetValue(item)?.ToString() ?? string.Empty;
|
||||
}
|
||||
return item.ToString();
|
||||
return item.ToString()!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user