2012-07-10 63 views
1

我怎樣才能通過後面的代碼寫下面的代碼。如何通過後面的代碼創建ComponentResourceKey?

<Style x:Key="{ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}"> 
    <Setter Property="TextBlock.Foreground" Value="#FF333333" /> 
</Style> 

這裏是我做的。

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; 
} 

回答

0

替代屬性的值是畫筆。

例如:

recordstyle.Setters.Add(new Setter(DataRecordCellArea.ForegroundAlternateStyleProperty, Brushes.Red)); 

任何刷是可能的。您不僅可以使用像我的示例中所示的實心畫筆,還可以使用漸變畫筆。