开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜