c# - Is it possible to reference a resource within a resource?
问题描述
So I know how I can declare a resource. A Color
for example
<Color x:Key="MyColorResource">#ffffff</Color>
But what if I want to use another resource within my resource. Something like this
<Color x:Key="Theme.Highlight">#ffffff</Color>
<Color x:Key="MyColorResource">{StaticResource Theme.Highlight}</Color>
Would this be possible?
解决方案
You can not directly reference inside an element.
You can reference one resource inside another resources property.
<Color x:Key="MyColorResource">#ffffff</Color>
<SolidColorBrush x:Key="MyBrushResource" Color="{StaticResource MyColorResource}" />
Note: your references should be compatible types.
推荐阅读
- matlab - 如何使用 exportdlg.m 将 MATLAB 中的图形导出到带有嵌入字体的 SVG?
- java - 在字符串字段上指定关键字类型
- json - 如何在 powershell 中编写此 json 有效负载
- java - 为什么迭代器打印哈希码不是实际值?
- javascript - 从匿名函数返回 JSON 或任何值 - AngularJS
- spring - 可完成的未来
状态码预期 - reactjs - Nuka-carousel 自定义箭头按钮
- c# - 将流写入文件和内存
- .htaccess - 将任何域从非 www 重定向到 www 和 HTTPS,无需双重重定向
- java - Java 8 转换地图
> 到地图 >