0
这是WPF GroupBox的样式。 我可以从App.xaml.cs中定义的属性中设置Groupbox背景和Groupbox边框颜色的值,如图所示。使用App.xaml.cs中的属性设置GroupBox标题模板的前景
<Style x:Key="StyleGroupBox1" TargetType="GroupBox">
<Setter Property="Background" >
<Setter.Value>
<Binding Path="GroupBox_Background" Source="{x:Static Application.Current}"/>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush">
<Setter.Value>
<Binding Path="Groupbox_BorderColor" Source="{x:Static Application.Current}"/>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="1,1,1,1"/>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding}" FontWeight="Bold" FontFamily="Palatino Linotype" FontSize="17" Foreground="DarkRed" FontStyle="Italic">
</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
如何设置分组框的相似,在我所设置的组框的背景和BORDERCOLOR(即从我app.xaml.cs定义的属性)的方式头模板的前景?即目前标题文本设置为DarkRed,但如何使用我的App.xaml.cs中的属性来设置它?
Vadim Moskvin:好吧,谈谈它......感谢..它的工作。我使用了错误的TargetType。我的错..:-)。 –