WPF: Resources in a GroupBox header
Can I do something like this?
<GroupBox.Header>
<GroupBox.Header.Resources>
<Style TargetType="Label">
<Setter Property="Foreground" Value="White"/>
</Style>
</Gr开发者_开发百科oupBox.Header.Resources>
<StackPanel Orientation="Horizontal">
<Label Content="Realtime Event Viewer" VerticalAlignment="Center"/>
<Label Content="Watching: " Margin="20,0,0,0" VerticalAlignment="Center"/>
<Label Content="{Binding MonitorServerName}" VerticalAlignment="Center"/>
</StackPanel>
</GroupBox.Header>
You're setting the Header property of a GroupBox object to a StackPanel object. If you want resources available in the Header, add them to the Resources of the StackPanel object:
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<StackPanel.Resources>
<Style TargetType="Label">
<Setter Property="Foreground" Value="White"/>
</Style>
</StackPanel.Resources>
<Label Content="Realtime Event Viewer" VerticalAlignment="Center"/>
<Label Content="Watching: " Margin="20,0,0,0" VerticalAlignment="Center"/>
<Label Content="{Binding MonitorServerName}" VerticalAlignment="Center"/>
</StackPanel>
</GroupBox.Header>
精彩评论