Bootstrap

WPF 修改标题栏背景色(标题栏的最小化、最大化、关闭需要调一下)

核心代码如下

<Style x:Key="StandardStyle" TargetType="{x:Type Window}">
    <Setter Property="shell:WindowChrome.WindowChrome">
        <Setter.Value>
            <shell:WindowChrome/>
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Window}" >
                <Grid>
                    <!--Title Panel-->
                    <DockPanel LastChildFill="True">
                        <Border  DockPanel.Dock="Top" 
                                Height="{x:Static SystemParameters.CaptionHeight}" x:Name="titlebar">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Offset="0.0" Color="#0F1E69"/>
                                        <GradientStop Offset="1.0" Color="#111729"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Border.Background>

                            <Grid>
                                <!--Title text only-->
                                <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" 
                            VerticalAlignment="Top" HorizontalAlignment="Center" Background="Transparent"  />
                                
                            </Grid>

                        </Border>
                        <!--Provides the actual content control-->
                        <Border Margin="0"  >
                            <AdornerDecorator>
                                <ContentPresenter Content="{TemplateBinding Content}"/>
                            </AdornerDecorator>
                        </Border>
                    </DockPanel>

                    <!--Provides the actual window border-->
                    <Border 
                                    Margin="0,0,0,0"
                                    Background="#F4F4F4"
                                    Grid.ZIndex="-1"
                                    BorderThickness="1,1,1,1" BorderBrush="White"
                                   >
                    </Border>

                    <!--This is the top left system button-->
                    <!--<Button
                            Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(shell:WindowChrome.WindowChrome).ResizeBorderThickness}"
                            Padding="1"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            shell:WindowChrome.IsHitTestVisibleInChrome="True"
                            Command="{x:Static shell:SystemCommands.ShowSystemMenuCommand}"
                            CommandParameter="{Binding ElementName=CalcWindow}">
                                <Image
                                Width="16"
                                Height="16"
                                shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon}" />
                            </Button>-->
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
;