开发者

Scrolling content with negative margins

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开发者_C百科,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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜