2017-03-23 2 views
0

기본 캡션 단추와 제목 표시 줄을 사용하여 창을 만들려고하고 있으며 여전히 창 크롬 내에 임의의 내용을 넣을 수 있습니다. 그러나, 내가 시도한 모든 솔루션 캡션 버튼 오른쪽에 약 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을 사용하는 더 안정적인 방법이 있다면 누군가가 내게 예제를 줄 수 있다면 감사하겠습니다.

답변

0
WindowChrome.WindowChrome> 
    <WindowChrome GlassFrameThickness="0.5,28,0,0.5" NonClientFrameEdges="Right"/> 
</WindowChrome.WindowChrome> 
<Window.Template> 
    <ControlTemplate> 
     <ContentPresenter Content="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window}, Path=Content}"/> 
    </ControlTemplate> 
</Window.Template> 

이것은 매우 오랜 시간이 걸렸습니다. 원래 WindowChrome 클래스가 완전히 망가 졌다고 생각했지만, 어느 정도까지는 그렇지만 어쨌든 그것을 사용했습니다. 필자가 생각해 낸 다른 솔루션은 훨씬 더 복잡했으며 결국에는 WindowChrome을 사용하여 손쉽게 시도해 보는 것이 훨씬 쉬워 보였습니다. Windows 10 전용 클래스의 수정 된 버전을 사용하겠습니다.하지만 그때까지는 작동합니다. 나는 이것이 누군가를 돕기를 바랍니다.

이 코드를 사용하려면이 코드를 XAML의 콘텐츠 영역 맨 위에 배치하면됩니다.