1
ControlTemplateを作成したいと思います。 ContentPresenterのテキストはスタイリングされていなければなりません。 contentpresenterでテキストブロックのスタイルを設定するには?使用WPF:ContentPresenterにTextBlockスタイルを適用する
<Style x:Key="PrimaryPanel" TargetType="GroupBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupBox">
<Border BorderThickness="1" BorderBrush="#337AB7">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Background="#337AB7">
<ContentPresenter ContentSource="Header">
<ContentPresenter.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#fff"></Setter>
<Setter Property="Margin" Value="0 -1 0 0"></Setter>
<Setter Property="Padding" Value="5"></Setter>
<Setter Property="VerticalAlignment" Value="Center"></Setter>
</Style>
</ContentPresenter.Resources>
</ContentPresenter>
</StackPanel>
<Border Grid.Row="1" Padding="10 5" Margin="5 0 5 10" >
<StackPanel>
<ContentPresenter />
</StackPanel>
</Border>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
:アドバイス
<GroupBox Style="{StaticResource PrimaryPanel}">
<GroupBox.Header>
<TextBlock Text="Title"/> this text must by styled
</GroupBox.Header>
</GroupBox>
おかげ これは私のコードです。