通常の窓のクロムを取り除き、エアロ効果のガラスに置き換えるスタイルがあります (コードは下部にあります)。
示された行を見ると、ガラスを暗くするためにブラック ボックスを使用していますが、半透明のままです (この例では、同様の目的でホワイト ボックスを使用しています)。私が抱えている問題は、ブラック ボックスがコントロール ボックスの上に表示されることです。ブラックボックスがある場合とない場合のウィンドウのスクリーンショット...
(メモ帳は参照用に含まれています)。ウィンドウを暗くしたいのですが、現在のアプローチではコントロールが使用できなくなります。また、フォームの上にホバリングしたときの赤い輝きX
が、フォームの外側では明るく、内側では暗いことに注意してください。
それで、私の具体的な質問は...「背景」レイヤーの上にコントロールボックスをレンダリングするにはどうすればよいですか?
より一般的には、これを行うためのより良い方法があるに違いないと感じていますか? エッジケースが多すぎるため、エミュレートしすぎることを嫌います。
私が達成しようとしているのは、(*現在機能している場合)ウィンドウです:
- 暗い(実際には機能していません)
- 通常の 3 つのコントロール ボタン (上記以外の場合はおそらく機能します)
- サイズ変更可能 *
- タイトルバー領域を使用してドラッグ可能 *
- 半透明※
- クロムとウィンドウの間に「コントロール」の境界線がありません *
解決策について私が何をする必要があるかを知っていただくために、その洗濯物のリストについてのみ言及します。私は .Net 4.5 を使用しています。これSystem.Shell.ChromeWindow
は、フレームワークに含まれていることを意味しますが、見つけることができるすべてのチュートリアルで言及されている古いバージョンとは少し異なるようです。
誰かが私を正しい方向に向けることができますか?
<Application.Resources>
<BitmapImage x:Key="MainIcon"
UriSource="./Resources/MainIcon.png" />
<Style x:Key="Chromeless"
TargetType="{x:Type Window}">
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome GlassFrameThickness="-1"
ResizeBorderThickness="4"
CaptionHeight="36" />
</Setter.Value>
</Setter>
<!--pack://application:,,,/Resources/Search.png-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Grid>
<!-- This is the ContentPresenter that displays the window content. -->
<Border Margin="0,40,0,25">
<ContentPresenter Content="{TemplateBinding Content}" />
</Border>
<!--This is the transparent white rectangle that goes behind the window content.-->
<!-- Window Border Content -->
<!-- HERE ----> <Border Margin="0"
BorderBrush="Gray"
BorderThickness="0,1,0,1"
Grid.ZIndex="-1">
<Rectangle Fill="Black"
Opacity="0.5" />
</Border>
<!-- System Button -->
<Button VerticalAlignment="Top"
HorizontalAlignment="Left"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
WindowChrome.IsHitTestVisibleInChrome="True"
Command="{x:Static SystemCommands.ShowSystemMenuCommand}"
CommandParameter="{Binding ElementName=LibraryWindow}"
BorderThickness="0">
<Image Source="{StaticResource MainIcon}"
Width="64"
Height="64"
WindowChrome.IsHitTestVisibleInChrome="True"
/>
</Button>
<!-- Window Title -->
<TextBlock VerticalAlignment="Top"
TextAlignment="Left"
FontSize="15"
Padding="40,8,0,0"
Foreground="White"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>