我用一些参数制作了一个窗口:
<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>
我想将高度和宽度更改为这些计算出的字符串。它获取用户的屏幕宽度和高度并将其除以四。
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 }" ??