デフォルトのキャプションボタンとタイトルバーを使用してウィンドウを作成しようとしていて、ウィンドウクロム内に任意のコンテンツを配置できるようにしようとしています。しかし、私が試したすべてのソリューションはキャプションボタンの右側に約5単位の余白を残しています。ここで基本的な例である:通常のキャプションボタンで非クライアント領域にコンテンツを正しく描画する方法
<Window x:Class="SemiCustomWindowChrome.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SemiCustomWindowChrome"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" Name="Window">
<WindowChrome.WindowChrome>
<WindowChrome UseAeroCaptionButtons="True" ResizeBorderThickness="5" GlassFrameThickness="1,28,1,1"/>
</WindowChrome.WindowChrome>
<Window.Template>
<ControlTemplate>
<AdornerDecorator>
<ContentPresenter Content="{Binding ElementName=Window, Path=Content}"/>
</AdornerDecorator>
</ControlTemplate>
</Window.Template>
<Grid>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<Button Content="Click me daddy!" WindowChrome.IsHitTestVisibleInChrome="True" Height="28"/>
<TextBlock Text="Custom Window Test" Margin="6.5"/>
</StackPanel>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontFamily="MS Calibri" FontWeight="ExtraLight" Text="Hello There"/>
</Grid>
上記のコードはthisを生成します。
明確にするために、ウィンドウクロムのキャプションボタンの右側にある白いパディングを削除して、ウィンドウが他のものとまったく同じになるようにしたいと思います。非クライアント領域(ウィンドウクロム)。 すべてのサポートが高く評価されています。
WindowChrome要素の使用を含まないDWMでもっと安定した方法がある場合は、誰かが私に例を挙げることができたらうれしいです。