Use ComponentResourceKey instead of strings to identify resources
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先定位当前使用字符串标识资源的资源字典声明和 XAML 用法。审查提议的静态 ComponentResourceKey 模式,并确定迁移范围。当资源使用经过编译器检查的键,并且向后兼容性或版本控制方面的决定已记录并验证时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem? Please describe.
- Currently resources are identified using strings. The string can only be validated at runtime and not while writing the XAML code
- When a resource key changes in a new version, the compiler does not indicate a problem and we get an Exception at runtime
Describe the solution you'd like
- Using
ComponentResourceKeywould make resources type-save - Optional: preserve the existing string-based resource keys for backward-compatibility, or increase the version number because of breaking changes
Describe alternatives you've considered
- Don't know a better way
Additional context
To create the resource key, you need to create a Component resource key in a static class:
public static partial class MaterialDesignColors
{
public static ComponentResourceKey Primary50Color { get; } = new(typeof(MaterialDesignColors), nameof(Primary50Color));
// ...
}
When declaring the resource in the ResouceDictionary, use the ComponentResourceKey as Key:
<Color Key="{x:Static md:MaterialDesignColors.Primary50Color}" ... />
When using the resource, we can now use a static reference that is checked by the compiler:
<Brush Color="{DynamicResource {x:Static md:MaterialDesignColors.Primary50Color}}" ... />
- 主要语言
- C#
- 星标
- 16.3k
- 派生
- 3.5k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MaterialDesignInXAML/MaterialDesignInXamlToolkit 的其他 Issue
-
enhancement up-for-grabs
难度 2/5 1-3 小时 新手友好度 68/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#2485 ·
维护者通常 1 天内回复
-
[Feature Request] Proposals for input/display improvements and hexadecimal support in NumericUpDown未关闭enhancement evaluation required
难度 5/5 一周以上 新手友好度 15/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#4108 ·
维护者通常 1 天内回复
-
enhancement evaluation required
难度 5/5 一周以上 新手友好度 25/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#3997 · 1 条评论 ·
维护者通常 1 天内回复
-
bug evaluation required
难度 3/5 1-2 天 新手友好度 45/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#3971 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement evaluation required
难度 5/5 一周以上 新手友好度 35/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#3903 · 5 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 MaterialDesignInXAML/MaterialDesignInXamlToolkit 的全部 Issue
相似的 Issue
-
documentation
难度 1/5 1-3 小时 新手友好度 62/100
-
bug misleading tooling trivial
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Docs example projects pinned to a literal library version instead of 3.*可能已有人在做 @DaveSkender 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
facioquo/stock-indicators-dotnet#2372 ·
维护者通常 1 天内回复
-
[Docs] officecli-docx SKILL.md still describes `\n` as a soft line break after #262可能已有人在做 @giprime 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
Facepunch/sbox-public#12097 ·
维护者通常 2 天内回复