1

コードビハインドを介してコードの下に書くにはどうすればよいですか。

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

1 に答える 1

0

代替プロパティの値はブラシです。

例えば:

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

任意のブラシが可能です。私の例のようにソリッド ブラシを使用できるだけでなく、グラデーション ブラシを使用することもできます。

于 2015-04-09T06:42:03.797 に答える