首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过后台代码创建ComponentResourceKey?

如何通过后台代码创建ComponentResourceKey?
EN

Stack Overflow用户
提问于 2012-07-10 19:49:13
回答 1查看 313关注 0票数 1

如何通过代码隐藏来编写下面的代码。

代码语言:javascript
复制
<Style x:Key="{ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}">
    <Setter Property="TextBlock.Foreground" Value="#FF333333" />
</Style>

这就是我要做的。

代码语言:javascript
复制
void ApplyRecordAreaStyle()
{
    Style recordstyle = new Style(typeof(DataRecordCellArea));

    recordstyle.Setters.Add(new Setter(DataRecordCellArea.BackgroundAlternateProperty, SelectedBackground));
    recordstyle.Setters.Add(new Setter(DataRecordCellArea.ForegroundAlternateStyleProperty, ????????));

    xamGrid.FieldLayoutSettings.DataRecordCellAreaStyle = recordstyle;
}
EN

回答 1

Stack Overflow用户

发布于 2015-04-09 14:42:04

替代属性的值für是笔刷。

例如:

代码语言:javascript
复制
recordstyle.Setters.Add(new Setter(DataRecordCellArea.ForegroundAlternateStyleProperty, Brushes.Red));

任何画笔都是可能的。您不仅可以使用实心笔刷,如我的例子所示,您还可以使用渐变笔刷。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11412686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档