c# - Accessing a DynamicResource in code-behind
问题描述
I'm fairly new to WPF and XAML, and I'm getting into the use of Resources.
In a ResourceDictionary, I have defined a SolidColorBrush thus:
<SolidColorBrush x:Key="ActiveTabBrush" Color="LightBlue" />
I use this in the XAML for my form like this:
Background="{DynamicResource ActiveTabBrush}"
I would also like to be able to access this SolidColorBrush in my C# code-behind, but I am at a loss to how to access such resources from code.
SolidColorBrush activeBrush = ?????;
Could somebody please tell me how I do this? I've spent a lot of time searching for the answer, but it's difficult to know what to search for.
解决方案
推荐阅读
- sql-server - 在 SQL Server 中按 * 分组
- amazon-cloudformation - 如何将保留策略添加到从 CloudFormation 创建的 AWS ElasticSearch?
- compiler-construction - x64 比较双打
- audio - 使用 ffmpeg 同步带有音频的视频文件正在返回没有音频的视频
- sql - 雪花服务器,按小时拆分持续时间?
- mongodb - 覆盖 UserClaimsPrincipalFactory generateclaimsasync 方法不会使声明坚持
- python - 无法正确识别 lamda 表达式类型
- ios - Xcode 10.3 中的 iOS 9 模拟器缺失
- flutter - Flutter Provider 重建不必要的小部件
- php - 无法使用 PHP 将数据插入 Postgres 数据库