Windows Presentation Foundation
.NET Framework 的一部分,它提供统一的编程模型,用于在 Windows 上构建业务线桌面应用程序。
65 个问题
问题 1:
当 Grid(UI 元素)放置在滚动查看器中时,我需要聚焦它。
<ScrollViewer>
<Grid x:Name="RootGrid">
<Border
Height="24"
Width="300"
Focusable="True"
Background="White"
BorderBrush="Silver"
BorderThickness="1"
SnapsToDevicePixels="True">
<Grid Background="Red" Focusable="True" x:Name="ViewGrid">
</Grid>
</Border>
</Grid>
</ScrollViewer>
面临的问题:
1.当我单击上面的控件时,滚动查看器是焦点元素,但我需要网格元素需要焦点。 请提出解决此问题的解决方案。
问题 2:
我有自定义控件。在更高的比例(如 125、150 等)中,边框和网格之间显示了不需要的空白,
<Grid x:Name="RootGrid">
<Border
Height="24"
Width="300"
Focusable="True"
Background="White"
BorderBrush="Silver"
BorderThickness="1"
SnapsToDevicePixels="True">
<Grid Background="Red" Focusable="True" x:Name="ViewGrid">
</Grid>
</Border>
</Grid>
</ScrollViewer
图像:
Note:此问题总结整理于:Need to focus the grid which placed inside the Scroll Viewer on Mouse Click
欢迎来到我们的 Microsoft 问答平台!
问题 1:
您可以尝试使用 FocusManager.FocusedElement:
<ScrollViewer FocusManager.FocusedElement="{Binding ElementName=RootGrid}">
<Grid x:Name="RootGrid" Width="200" Height="200" >
<Border
Height="24"
Width="300"
Focusable="True"
Background="White"
BorderBrush="Silver"
BorderThickness="1"
SnapsToDevicePixels="True">
<Grid Background="Red" Focusable="True" x:Name="ViewGrid">
</Grid>
</Border>
</Grid>
</ScrollViewer>
问题 2:
如果设置 BorderThickness=“0”,白色 spack 仍然存在?
如果答案是正确的,请点击“接受答案”并点赞。 如果您对此答案还有其他疑问,请点击“评论”。
注意:如果您想接收相关电子邮件,请按照我们的文档中的步骤启用电子邮件通知 此线程的通知。