将面板中子控件的大小限制为可见区域
我似乎永远无法理解 DockPanel、StackPanel 和 Grid 在限制其子内容方面的差异。此 XAML:
<DockPanel>
<Menu/>
<ToolBarTray/>
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Data" Name="tabData">
<DockPanel>
<Border Name="extraDataBorder" DockPanel.Dock="Top"
Style="{StaticResource ConsistentBorder}" Margin="10">
</Border>
<igDP:XamDataGrid Grid.Row="1"
Margin="10,10,10,0"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible" >
</igDP:XamDataGrid>
</DockPanel>
</TabItem>
</TabControl>
</Grid>
</ScrollViewer>
</DockPanel>
生成不受屏幕可见区域限制的网格,如下图所示:
我不希望网格超出屏幕的可见区域。相反,我希望将其剪裁,以便用户可以看到水平滚动条,而不必向下滚动才能看到水平滚动条。我尝试使用 Stack 和 DockPanel 代替网格,但得到了完全相同的效果。我该如何解决这个问题?
TIA。
编辑: 我正在编辑原始 XAML 以包含导致此问题的其他元素。
I can never seem to wrap my head around the differences between the DockPanel, StackPanel and Grid in terms of restricting their children content. This XAML:
<DockPanel>
<Menu/>
<ToolBarTray/>
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Data" Name="tabData">
<DockPanel>
<Border Name="extraDataBorder" DockPanel.Dock="Top"
Style="{StaticResource ConsistentBorder}" Margin="10">
</Border>
<igDP:XamDataGrid Grid.Row="1"
Margin="10,10,10,0"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible" >
</igDP:XamDataGrid>
</DockPanel>
</TabItem>
</TabControl>
</Grid>
</ScrollViewer>
</DockPanel>
Produces a grid that is not constrained within the visible area of the screen as shown in the figure below:
I do not want the grid to extent beyond the visible area of the screen. Instead, I want it clipped so that users can see the horizontal scroll bar and not have to scroll down to see the horizontal scroll bar. I have tried using a Stack and DockPanel in place of the grid but get the exact same effect. How do I fix this?
TIA.
EDIT:
I am editing the original XAML to include the additional elements that caused this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为众多解决方案之一,您可以将其绑定到其父级的宽度和高度。
You can bind it to its parent's width and height as one of the many solutions.