10

WindowChrome クラスを使用してウィンドウの境界線をカスタマイズしようとしています。Windows Aero ガラス効果なし。案の定、ブラックボーダーに仕上がってしまいます。しかし、キャプションボタンもありません

Microsoft から、これらの問題を克服するためにウィンドウ スタイルを null に設定することで標準ウィンドウを使用できることを学びました http://msdn.microsoft.com/en-us/library/microsoft.windows.shell.windowchrome.aspx

しかし、私はそれで成功しません。

誰かがこれの実例を持っていますか? または、私の問題を解決する方法を説明できる何らかのリンクはありますか?

簡単なサンプル コードを作成して、WindowStyle を none に変更しようとしましたが、うまくいきません。これは私のコード例です:

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

1 に答える 1

5

私も WindowChrome を試していますが、私のアプリケーションはこれまでのところ動作します:

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

上記のコードを使用すると、キャプション ボタンとガラス ウィンドウ以外の何もない空のウィンドウが表示されます。

于 2012-06-26T10:43:05.460 に答える