Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
[WPF] ネストしたスタイルを定義する (NestedStyles in WPF)
<Window x:Class="NestedStyles.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Style TargetType="{x:Type Button}">
<Setter Property="MinWidth" Value="100" />
<Style x:Key="RootStyle" TargetType="{x:Type Grid}">
<Setter Property="Margin" Value="5" />
<Style TargetType="{x:Type StackPanel}">
<Setter Property="Margin" Value="5, 0, 5, 0" />
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="MinHeight" Value="50" />
<Style x:Key="ButtonAreaStyle" TargetType="{x:Type StackPanel}">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Margin" Value="10, 10, 10, 0" />
<Setter Property="MinHeight" Value="60" />
<Grid x:Name="LayoutRoot" Style="{StaticResource RootStyle}">
<RowDefinition />
<RowDefinition Height="Auto" />
<Grid Grid.Row="0">
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ListBox Grid.Column="0" />
<StackPanel Orientation="Vertical" Grid.Column="1">
<Button Content="Refresh" />
<StackPanel Style="{StaticResource ButtonAreaStyle}" Grid.Row="1">
<Button Content="Yes" />
<Button Content="No" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment