SPREAD for WPF 3.0J - GcSpreadGrid
NamedStyleInfos プロパティ
使用例 

GrapeCity.Windows.SpreadGrid 名前空間 > GcSpreadGrid クラス : NamedStyleInfos プロパティ
StyleInfo とその名前を含むディクショナリーを取得します。StyleInfo は名前によって参照できます。このディクショナリーは、異なる用途で StyleInfo を共有するために使用されます。
シンタックス
'宣言
 
Public ReadOnly Property NamedStyleInfos As NamedStyleInfoDictionary
public NamedStyleInfoDictionary NamedStyleInfos {get;}

プロパティ値

StyleInfo とその名前を含む NamedStyleInfoDictionary
使用例
次のサンプルは NamedStyleInfos を使用して2つのスキン "Dark" と "Light" を実行時に変更します。
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<sg:GcSpreadGrid x:Name="gcSpreadGrid1" ShowResizeTip="Both" ShowScrollTip="Both" />
<StackPanel Grid.Row="1" Margin="10" Orientation="Horizontal" ButtonBase.Click="StackPanel_Click_1">
<RadioButton Content="Dark" VerticalAlignment="Center" Margin="10"/>
<RadioButton Content="Light" VerticalAlignment="Center" Margin="10" IsChecked="True"/>
</StackPanel>
</Grid>
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
gcSpreadGrid1.DefaultStyleName = "Default";
gcSpreadGrid1.NewRowStyleName = "Cell1";
gcSpreadGrid1.Columns[1].StyleName = "Column";
gcSpreadGrid1.CornerHeader.DefaultStyleName = "Header";
gcSpreadGrid1.ColumnHeader.DefaultStyleName = "Header";
gcSpreadGrid1.RowHeader.AlternatingRows.Add(new AlternatingRow() { StyleName = "Header" });
gcSpreadGrid1.RowHeader.AlternatingRows.Add(new AlternatingRow() { StyleName = "Header1" });
gcSpreadGrid1.AlternatingRows.Add(new AlternatingRow() { StyleName = "Cell" });
gcSpreadGrid1.AlternatingRows.Add(new AlternatingRow() { StyleName = "Cell1" });
gcSpreadGrid1.Rows[0].StyleName = "Cell1";
gcSpreadGrid1[1, 0].StyleName = "Cell";
gcSpreadGrid1.HighlightHeader = HighlightHeader.None;

ChangeToLight();
}

private void StackPanel_Click_1(object sender, RoutedEventArgs e)
{
var radio = e.Source as RadioButton;
if (radio == null)
{
return;
}

if (Equals(radio.Content, "Dark"))
{
ChangeToDark();
}
else
{
ChangeToLight();
}
}

private void ChangeToLight()
{
StyleInfo defaultStyle = new StyleInfo();
defaultStyle.Background = Brushes.LightBlue;
defaultStyle.Foreground = Brushes.Black;
gcSpreadGrid1.NamedStyleInfos["Default"] = defaultStyle;
StyleInfo columnStyle = new StyleInfo();
columnStyle.Background = Brushes.LightGreen;
columnStyle.Foreground = Brushes.Black;
gcSpreadGrid1.NamedStyleInfos["Column"] = columnStyle;
StyleInfo headerStyle = new StyleInfo();
headerStyle.Background = Brushes.DarkOliveGreen;
headerStyle.Foreground = Brushes.White;
gcSpreadGrid1.NamedStyleInfos["Header"] = headerStyle;
StyleInfo headerStyle2 = new StyleInfo();
headerStyle2.Background = Brushes.SeaGreen;
headerStyle2.Foreground = Brushes.White;
gcSpreadGrid1.NamedStyleInfos["Header1"] = headerStyle2;
StyleInfo cellStyle = new StyleInfo();
cellStyle.Background = Brushes.PaleGreen;
cellStyle.Foreground = Brushes.Black;
gcSpreadGrid1.NamedStyleInfos["Cell"] = cellStyle;
StyleInfo cellStyle2 = new StyleInfo();
cellStyle2.Background = Brushes.Honeydew;
cellStyle2.Foreground = Brushes.Black;
gcSpreadGrid1.NamedStyleInfos["Cell1"] = cellStyle2;
}

private void ChangeToDark()
{
StyleInfo defaultStyle = new StyleInfo();
defaultStyle.Background = Brushes.DarkSlateBlue;
defaultStyle.Foreground = Brushes.White;
gcSpreadGrid1.NamedStyleInfos["Default"] = defaultStyle;
StyleInfo columnStyle = new StyleInfo();
columnStyle.Background = Brushes.DarkSeaGreen;
columnStyle.Foreground = Brushes.White;
gcSpreadGrid1.NamedStyleInfos["Column"] = columnStyle;
StyleInfo headerStyle = new StyleInfo();
headerStyle.Background = Brushes.Black;
headerStyle.Foreground = Brushes.White;
gcSpreadGrid1.NamedStyleInfos["Header"] = headerStyle;
StyleInfo headerStyle2 = new StyleInfo();
headerStyle2.Background = Brushes.DarkSlateGray;
headerStyle2.Foreground = Brushes.White;
gcSpreadGrid1.NamedStyleInfos["Header1"] = headerStyle2;
StyleInfo cellStyle = new StyleInfo();
cellStyle.Background = Brushes.DarkSlateGray;
cellStyle.Foreground = Brushes.White;
gcSpreadGrid1.NamedStyleInfos["Cell"] = cellStyle;
StyleInfo cellStyle2 = new StyleInfo();
cellStyle2.Background = Brushes.DarkGray;
cellStyle2.Foreground = Brushes.White;
gcSpreadGrid1.NamedStyleInfos["Cell1"] = cellStyle2;
}
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs)
gcSpreadGrid1.DefaultStyleName = "Default"
gcSpreadGrid1.NewRowStyleName = "Cell1"
gcSpreadGrid1.Columns(1).StyleName = "Column"
gcSpreadGrid1.CornerHeader.DefaultStyleName = "Header"
gcSpreadGrid1.ColumnHeader.DefaultStyleName = "Header"
gcSpreadGrid1.RowHeader.AlternatingRows.Add(New AlternatingRow() With { _
.StyleName = "Header" _
})
gcSpreadGrid1.RowHeader.AlternatingRows.Add(New AlternatingRow() With { _
.StyleName = "Header1" _
})
gcSpreadGrid1.AlternatingRows.Add(New AlternatingRow() With { _
.StyleName = "Cell" _
})
gcSpreadGrid1.AlternatingRows.Add(New AlternatingRow() With { _
.StyleName = "Cell1" _
})
gcSpreadGrid1.Rows(0).StyleName = "Cell1"
gcSpreadGrid1(1, 0).StyleName = "Cell"
gcSpreadGrid1.HighlightHeader = HighlightHeader.None

ChangeToLight()
End Sub

Private Sub StackPanel_Click_1(sender As Object, e As RoutedEventArgs)
Dim radio = TryCast(e.Source, RadioButton)
If radio Is Nothing Then
Return
End If

If Equals(radio.Content, "Dark") Then
ChangeToDark()
Else
ChangeToLight()
End If
End Sub

Private Sub ChangeToLight()
Dim defaultStyle As New StyleInfo()
defaultStyle.Background = Brushes.LightBlue
defaultStyle.Foreground = Brushes.Black
gcSpreadGrid1.NamedStyleInfos("Default") = defaultStyle
Dim columnStyle As New StyleInfo()
columnStyle.Background = Brushes.LightGreen
columnStyle.Foreground = Brushes.Black
Dim headerStyle As New StyleInfo()
headerStyle.Background = Brushes.DarkOliveGreen
headerStyle.Foreground = Brushes.White
gcSpreadGrid1.NamedStyleInfos("Header") = headerStyle
Dim headerStyle2 As New StyleInfo()
headerStyle2.Background = Brushes.SeaGreen
headerStyle2.Foreground = Brushes.White
gcSpreadGrid1.NamedStyleInfos("Header1") = headerStyle2
Dim cellStyle As New StyleInfo()
cellStyle.Background = Brushes.PaleGreen
cellStyle.Foreground = Brushes.Black
gcSpreadGrid1.NamedStyleInfos("Cell") = cellStyle
Dim cellStyle2 As New StyleInfo()
cellStyle2.Background = Brushes.Honeydew
cellStyle2.Foreground = Brushes.Black
gcSpreadGrid1.NamedStyleInfos("Cell1") = cellStyle2
End Sub

Private Sub ChangeToDark()
Dim defaultStyle As New StyleInfo()
defaultStyle.Background = Brushes.DarkSlateBlue
defaultStyle.Foreground = Brushes.White
gcSpreadGrid1.NamedStyleInfos("Default") = defaultStyle
Dim columnStyle As New StyleInfo()
columnStyle.Background = Brushes.DarkSeaGreen
columnStyle.Foreground = Brushes.White
Dim headerStyle As New StyleInfo()
headerStyle.Background = Brushes.Black
headerStyle.Foreground = Brushes.White
gcSpreadGrid1.NamedStyleInfos("Header") = headerStyle
Dim headerStyle2 As New StyleInfo()
headerStyle2.Background = Brushes.DarkSlateGray
headerStyle2.Foreground = Brushes.White
gcSpreadGrid1.NamedStyleInfos("Header1") = headerStyle2
Dim cellStyle As New StyleInfo()
cellStyle.Background = Brushes.DarkSlateGray
cellStyle.Foreground = Brushes.White
gcSpreadGrid1.NamedStyleInfos("Cell") = cellStyle
Dim cellStyle2 As New StyleInfo()
cellStyle2.Background = Brushes.DarkGray
cellStyle2.Foreground = Brushes.White
gcSpreadGrid1.NamedStyleInfos("Cell1") = cellStyle2
End Sub
参照

GcSpreadGrid クラス
GcSpreadGrid メンバ