以负边距滚动内容
我已经从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于这项任务来说,网格是错误的。如果您要自己进行定位,则应使用
Canvas
,然后使用Canvas.Left
和Canvas.Top
定位它。您不需要Bottom
或Right
值,因为您似乎知道Width
和Height
。我相信您也应该能够在
Canvas
对象周围使用ScrollViewer
。The
Grid
is the wrong thing for this task. If you're going to do the positioning yourself, you should use aCanvas
and then useCanvas.Left
andCanvas.Top
to position it. You don't need theBottom
orRight
values since you seem to know theWidth
andHeight
.I believe you should be able to use the
ScrollViewer
around theCanvas
object too.