diff --git a/YKanBan/Assets/Locales/Resources.resx b/YKanBan/Assets/Locales/Resources.resx
index 5a09083..e954f47 100644
--- a/YKanBan/Assets/Locales/Resources.resx
+++ b/YKanBan/Assets/Locales/Resources.resx
@@ -343,6 +343,9 @@
The change could not be written to the workspace. The board shows the stored state.
+
+ View not found: {0}
+
Reading failed
diff --git a/YKanBan/Assets/Locales/Resources.zh-Hans.resx b/YKanBan/Assets/Locales/Resources.zh-Hans.resx
index 31320d4..3a99db3 100644
--- a/YKanBan/Assets/Locales/Resources.zh-Hans.resx
+++ b/YKanBan/Assets/Locales/Resources.zh-Hans.resx
@@ -343,6 +343,9 @@
更改未能写入工作区,看板显示的是已保存的状态。
+
+ 找不到视图:{0}
+
读取失败
diff --git a/YKanBan/ViewLocator.cs b/YKanBan/ViewLocator.cs
index 651f07e..4de99af 100644
--- a/YKanBan/ViewLocator.cs
+++ b/YKanBan/ViewLocator.cs
@@ -1,31 +1,34 @@
-using System;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using YKanBan.ViewModels;
namespace YKanBan;
+///
+/// Resolves the view of a view model by naming convention: the type name with
+/// "ViewModel" replaced by "View". A missing view is a programming error; it
+/// shows a localized placeholder naming the type that was looked for.
+///
public class ViewLocator : IDataTemplate
{
-
+ ///
public Control? Build(object? param)
{
if (param is null)
+ {
return null;
-
- var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
- var type = Type.GetType(name);
+ }
- if (type != null)
+ string name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
+ Type? type = Type.GetType(name);
+ if (type is not null)
{
return (Control)Activator.CreateInstance(type)!;
}
-
- return new TextBlock { Text = "Not Found: " + name };
+
+ return new TextBlock { Text = string.Format(YKanBan.Resources.Culture, YKanBan.Resources.Error_ViewNotFound, name) };
}
- public bool Match(object? data)
- {
- return data is ViewModelBase;
- }
+ ///
+ public bool Match(object? data) => data is ViewModelBase;
}