ControlTemplate 中 Bingding 附加属性时需要加入 Path
<Style TargetType="{x:Type GroupBox}" BasedOn="{StaticResource MaterialDesignGroupBox}"> <Setter Property="Background" Value="Transparent"/> <Setter Property="Foreground" Value="{Binding (TextElement.Foreground), RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type FrameworkElement}}}"/> Property="materialDesignMahApps:ShadowAssist.ShadowDepth" Value="Depth0"/> <Setter Property="materialDesignMahApps:ColorZoneAssist.Mode" Value="PrimaryMid"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupBox}"> <DockPanel Background="{TemplateBinding Background}"> <materialDesignMahApps:ColorZone Background="{StaticResource PrimaryHueMidBrush}" x:Name="PART_ColorZone" DockPanel.Dock="Top" Mode="{Binding Path=(materialDesignMahApps:ColorZoneAssist.Mode), RelativeSource={RelativeSource TemplatedParent}}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" materialDesignMahApps:ShadowAssist.ShadowEdges="{Binding Path=(materialDesignMahApps:ShadowAssist.ShadowEdges), RelativeSource={RelativeSource TemplatedParent}}" UseLayoutRounding="True"> <ContentControl HorizontalAlignment="Left" Foreground="White" VerticalAlignment="Center" FontSize="20" FontWeight="DemiBold" Margin="10 0 0 4" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" Content="{TemplateBinding Header}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> </materialDesignMahApps:ColorZone> <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> </DockPanel> </ControlTemplate> </Setter.Value> </Setter> </Style>