新規作成日 2020-01-28
最終更新日
WPFでデザイン重視のアプリケーションを作成する際、Windowsアプリケーションの特徴である枠が邪魔になります。WPFでは、この枠の表示は簡単に非表示にできます。
ウィンドウの枠を非表示にする
WPFアプリケーションで、ウィンドウの枠を非表示にするためには、Windowタグで、プロパティに、「WindowStyle=None」、「AllowTransparency=true 」にすれば良いと書かれていたので、試してみました。
XAML
<Window x:Class="NoWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="150" Width="200"
WindowStyle="None" AllowsTransparency="True">
<Grid>
<Button Name="btn0" HorizontalAlignment="Center" VerticalAlignment="Center"
Width="100" Height="50">
押してね。
</Button>
</Grid>
</Window>
実行結果

このコードだと、枠は、消えたけど、ウィンドウの背景色は、表示されたままです。
参考サイト
ウィンドウの背景色を透明にする
背景色を透明にするには、さらに、「Background="Transparent"」を追加するとよいという情報見つけた。
XAML
<Window x:Class="NoWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="150" Width="200"
WindowStyle="None" AllowsTransparency="True" Background="Transparent">
<Grid>
<Button Name="btn0" HorizontalAlignment="Center" VerticalAlignment="Center"
Width="100" Height="50">
押してね。
</Button>
</Grid>
</Window>
実行結果

参考サイト
ウィンドウを常に最前面に表示する
ウィンドウを常に最前面に表示するには、「Topmost="True"」を指定します。
XAML
<Window x:Class="NoWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="150" Width="200"
WindowStyle="None" AllowsTransparency="True" Background="Transparent"
Topmost="True">
<Grid>
<Button Name="btn0" HorizontalAlignment="Center" VerticalAlignment="Center"
Width="100" Height="50">
押してね。
</Button>
</Grid>
</Window>
参考サイト
全画面表示
