From 6bc77672e970d2fe6f3710fce6db31aa4e82ee46 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Wed, 3 Jun 2026 19:49:44 +0800 Subject: [PATCH] fix: prevent crash when invalid characters typed in coordinate editor EditableNumberConverter.ConvertBack was throwing FormatException when users typed '=' or other non-numeric characters, causing WPF binding validation to crash the application on focus change. Changed to return Binding.DoNothing to silently reject invalid input. --- src/UI/WPF/Converters/EditableNumberConverter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UI/WPF/Converters/EditableNumberConverter.cs b/src/UI/WPF/Converters/EditableNumberConverter.cs index ee7886a..4141730 100644 --- a/src/UI/WPF/Converters/EditableNumberConverter.cs +++ b/src/UI/WPF/Converters/EditableNumberConverter.cs @@ -36,7 +36,7 @@ namespace NavisworksTransport.UI.WPF.Converters string text = value as string; if (IsIntermediateText(text)) { - throw new FormatException("请输入有效的数字。"); + return Binding.DoNothing; } text = text.Trim(); @@ -47,7 +47,7 @@ namespace NavisworksTransport.UI.WPF.Converters return parsedValue; } - throw new FormatException("请输入有效的数字。"); + return Binding.DoNothing; } public static bool IsIntermediateText(string text)