概要
この記事では、WPF の GridSplitter コントロールのBackground プロパティを使用して、背景色を変更する方法について解説します。
構文
XAML の構文:
GridSplitter Background="color" />
コードビハインドの構文:
GridSplitter.Background = new SolidColorBrush(color);
Background プロパティは、GridSplitter コントロールの背景色を設定するために使用されます。XAML では、Backgroundプロパティに直接色を指定します。コードビハインドでは、Backgroundプロパティに色を指定するために、SolidColorBrush クラスのインスタンスを作成して代入します。
使用例
XAML の例:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width=" Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Left" />
<GridSplitter Grid.Column="1" Width="5" Background="Blue"/>
<TextBlock Grid.Column="2" Text="Right" />
</Grid>
コードビハインドの例:
GridSplitter GridSplitter = new GridSplitter(); GridSplitter.Background = new SolidColorBrush(Colors.Blue); GridSplitter.horizontalAlignment = horizontalAlignment.Center; GridSplitter.Width = 5;
この例では、Background プロパティにBlueを指定して、青色のGridSplitterを配置しています。
まとめ
この記事では、WPF の GridSplitter コントロールのBackground プロパティを使用して、背景色を変更する方法について解説しました。これによりGridSplitter コントロールの背景色を目立たせることができます。
その他の WPF Tips
その他の WPF Tips 一覧はコチラ
Please follow and like us:


コメント