以负边距滚动内容

发布于 2024-11-07 14:10:12 字数 570 浏览 0 评论 0原文

我已经从 Windows 窗体生成了 XAML 文件,并通过该过程计算了右侧和底部边距,因为它们在窗体中不存在。我有这样的输出:

<Grid>
    <TextBox Width="129" Height="18" Margin="36,46,278,686" />
    ...
    <TextBox Width="54" Height="18" Margin="345,705,83,31" />
    <TextBox Width="54" Height="18" Margin="345,728,83,8" />
    <TextBox Width="54" Height="18" Margin="345,770,83,-34" /> 
    ...
</Grid>

问题是网格内容太大,即使对于设计者来说也是如此,因此滚动条是在 win 表单中生成的。但是,WPF 中并非如此,因此我尝试在其周围添加 ScrollViewer。但它只会向下滚动到具有正底部边距的内容。具有负边距的控件不会在任何地方显示。

任何如何解决这个问题的想法都值得赞赏。

I have generated XAML file from Windows Forms, and with the process calculated right and bottom margins because they do not exist in Forms. I have this output:

<Grid>
    <TextBox Width="129" Height="18" Margin="36,46,278,686" />
    ...
    <TextBox Width="54" Height="18" Margin="345,705,83,31" />
    <TextBox Width="54" Height="18" Margin="345,728,83,8" />
    <TextBox Width="54" Height="18" Margin="345,770,83,-34" /> 
    ...
</Grid>

The problem is that Content of Grid is too large, even for the designer, so scroll bar is generated in win forms. However, this is not case in WPF, so I try adding ScrollViewer around it. But it only scrolls down to content with positive bottom margin. Controls with negative margins are not shown anywhere.

Any idea how to solve this is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆消瘦 2024-11-14 14:10:12

对于这项任务来说,网格是错误的。如果您要自己进行定位,则应使用 Canvas,然后使用 Canvas.LeftCanvas.Top 定位它。您不需要 BottomRight 值,因为您似乎知道 WidthHeight

我相信您也应该能够在 Canvas 对象周围使用 ScrollViewer

The Grid is the wrong thing for this task. If you're going to do the positioning yourself, you should use a Canvas and then use Canvas.Left and Canvas.Top to position it. You don't need the Bottom or Right values since you seem to know the Width and Height.

I believe you should be able to use the ScrollViewer around the Canvas object too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文