我正在尝试使用 获取视口高度大小window.innerHeight。但它的返回值似乎是错误的。
我尝试window.outerHeight过并且window.innerHeight。
我也添加了视口元标记。
<meta name="viewport" content="height=device-height; width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no">
console.log("viewport_inner_height: " + window.innerHeight);
console.log("viewport_outer_height: " + window.outerHeight);
Run Code Online (Sandbox Code Playgroud)
结果是:
viewport_inner_height: 2044
viewport_outer_height: 1047
Run Code Online (Sandbox Code Playgroud)
window.outerHeight 似乎是正确的。
如何通过javascript准确获取视口高度?
我认为我们可以在带有XAML的窗口上使用多种布局.所以我尝试创建一个这样的窗口:我想在左边创建一个ListView,它可以调整大小.左侧的网格和文本框将适合右侧网格.我试图使用其他布局,StackPanel,DockPanel.如何创建可调整大小的网格
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ToolBar Name="toolBar" Grid.Row="0">
<Button Name="btnLoad" Width="Auto" Height="25" ToolTip= Click="btnLoad_Click" VerticalAlignment="Bottom">
<StackPanel Orientation="Horizontal">
<Image Source="Resources/reload.png" Width="16" Height="16" HorizontalAlignment="Left" Margin="0 0 5 0"/>
<TextBlock>Load/Reload</TextBlock>
</StackPanel>
</Button>
<Button Name="btnSave" Width="Auto" Height="25" Click="btnSave_Click">
<StackPanel Orientation="Horizontal">
<Image Source="Resources/save.png" Width="16" Height="16" HorizontalAlignment="Left" Margin="0 0 5 0"/>
<TextBlock>Save</TextBlock>
</StackPanel>
</Button>
</ToolBar>
<ComboBox Name="cbTypeOfShop" Grid.Row="1" Margin="5 5 5 5"/>
<Grid Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ListView Grid.Column="0" VerticalAlignment="Stretch" …Run Code Online (Sandbox Code Playgroud)