いくつかのパラメーターを使用してウィンドウを作成しました。
<Window x:Class="MsgBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MsgBox" Height="300" Width="500" Topmost="True" WindowStartupLocation="CenterScreen" WindowStyle="None" Loaded="MsgBox_Loaded">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</Window>
高さと幅をこれらの計算された文字列に変更したいと思います。ユーザーの画面幅と高さを取得し、それを 4 で割ります。
Public ReadOnly Property PrimaryScreenWidth As Double
Get
Return System.Windows.SystemParameters.PrimaryScreenWidth
End Get
End Property
Public ReadOnly Property PrimaryScreenHeight As Double
Get
Return System.Windows.SystemParameters.PrimaryScreenHeight
End Get
End Property
Private MsgBoxWidth As String = PrimaryScreenWidth \ 4
Private MsgBoxHeight As String = PrimaryScreenHeight \ 4
ウィンドウに設定する方法は?
Height="{x:static MsgBoxHeight }" Width="{x:static MsgBoxWidth }" ??