如何使画布自动增长以适应其内容

时间:2021-10-26 21:12:11

I am creating a portal type dashboard for our app. The controls are added on the fly. I have a page, with a tabcontrol. In the tab control I add TabItems on the fly with a canvas on it. The canvas handles the mouse events to move the controls around.

我正在为我们的应用创建门户类型仪表板。控件即时添加。我有一个页面,带有tabcontrol。在选项卡控件中,我在其上添加了TabItems,并在其上添加了一个画布。画布处理鼠标事件以移动控件。

I need to allow the users to create a layout bigger than the current size of the tab item... so I inserted a scrollviewer in the tab item and put the canvas onto it. However, the canvas doesn't seem to expand automatically to contain the content.

我需要允许用户创建一个大于选项卡项当前大小的布局...所以我在选项卡项中插入了一个scrollviewer并将画布放到它上面。但是,画布似乎不会自动展开以包含内容。

How can I made the canvas expand to hold all its content within the scroll viewer which will allow me to scroll around the canvas it contains?

如何使画布展开以在滚动查看器中保存其所有内容,这将允许我滚动它包含的画布?

1 个解决方案

#1


1  

Check these two previous SO posts on how to manipulate the size of a Canvas:

检查这两个以前的SO文章,了解如何操纵Canvas的大小:

#1


1  

Check these two previous SO posts on how to manipulate the size of a Canvas:

检查这两个以前的SO文章,了解如何操纵Canvas的大小: