开发者

How to use WindowChrome without Windows Aero glass effects in wpf, black border

I'm trying to customize a window border by using the WindowChrome class. Without Windows Aero glass effects. As expected I end up with a black boarder. But i also end up without caption buttons

From Microsoft i learn that i can use the standard window by setting the window style to null to overcome these problem http://msdn.microsoft.com/en-us/library/microsoft.windows.shell.windowchrome.aspx

But i do not succeed with that.

Do anyone have a working example of this? Or a link of some sort that can explain how to solve my problem?

I have tried 开发者_Go百科to do a simple example code, and change the WindowStyle to none but it wont work. This is my example code:

<Window x:Class="WpfApplication1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell" Title="Window" Height="400" Width="500">
    <Window.Style>
        <Style 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>
                            <Border Background="White" Margin="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowNonClientFrameThickness}">
                                <ContentPresenter Content="{TemplateBinding Content}" />
                            </Border>
                            <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" 
                               VerticalAlignment="Top" HorizontalAlignment="Left" 
                               Margin="36,8,0,0"/>
                            <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon}"
                           VerticalAlignment="Top" HorizontalAlignment="Left"
                           Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(shell:WindowChrome.WindowChrome).ResizeBorderThickness}" 
                           Width="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=SmallIconSize.Width}"
                           shell:WindowChrome.IsHitTestVisibleInChrome="True"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Style>
    <Grid/>
</Window>


I'm experimenting with WindowChrome too and my application works so far:

<Window ...>
    <Window.Style>
        <Style TargetType="{x:Type Window}">
            <Setter Property="shell:WindowChrome.WindowChrome">
                <Setter.Value>
                    <shell:WindowChrome CaptionHeight="15"
                                        CornerRadius="0"
                                        GlassFrameThickness="0,0,0,-1"
                                        NonClientFrameEdges="None"
                                        ResizeBorderThickness="5"
                                        UseAeroCaptionButtons="true"/>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Style>
    <!-- Add content to normal window content (not with template, at first) -->
    <Grid>

    </Grid>
</Window>

You should have an empty window with nothing more than the caption buttons and a glass window if you use my code above.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜