如何在窗口标题栏上添加选项卡控件

时间:2016-05-09 02:19:18

标签: c# wpf-controls

我想将标签控件标题(或样式列表框)添加到Windows标题栏中,如下所示:

New window title bar

我计划编辑窗口模板来实现这一目标。但我不知道在哪里添加。这是我在Blend中编辑的窗口模板:

<ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type Window}">
        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
            <Grid>
                <AdornerDecorator>
                    <ContentPresenter/>
                </AdornerDecorator>
                <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                    <Condition Property="WindowState" Value="Normal"/>
                </MultiTrigger.Conditions>
                <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style x:Key="WindowStyle1" TargetType="{x:Type Window}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                        <AdornerDecorator>
                            <ContentPresenter/>
                        </AdornerDecorator>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="ResizeMode" Value="CanResizeWithGrip">
                <Setter Property="Template" Value="{StaticResource WindowTemplateKey}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

1 个答案:

答案 0 :(得分:0)

事实证明,如果我不想处理按钮并自行拖动,我必须使用第三方控件(例如Actiprosoftware)。它为我处理一切,同时提供了一个更加可扩展的模板。