我正在开发一个仪表板应用程序,我想让用户在画布上调整小部件的大小。环顾四周,对我来说最好的解决方案似乎是使用 Microsoft 的 ResizingAdorner 类。该示例可以在此处找到,代码可以在此处(大约页面下方四分之一处)。一切似乎都正常,直到我单击其中一个小部件(来自 ComponentOne 的图表控件)。右下角装饰器和右上角装饰器似乎出现在大约的宽度和从侧面的高度移动时的画布。请参阅下面的示例:
我去过 StackOverflow 问题 这里关于使用网格分割器,但这对我不起作用,因为控件将重叠网格列。
我也遇到过类似的问题,但第一个答案根本不起作用,第二个答案仅仅指向博客,这位先生要么为微软工作并创建了 ResizingAdorner 类,要么只是复制了来自 wpf 示例站点的代码。我也尝试过修改代码这里< /a> 但没有运气。
有没有我没有看到的快速修复
I am working on a dashboard application where I would like to let the user resize the widgets on a canvas. Looking around, the best solution to me seemed to use Microsoft's ResizingAdorner class. The example can be found here and the code can be found here (About a quarter way down the page). Everything seemed to work until I clicked one of the widgets (chart controls from ComponentOne). The bottom right adorner and the top right adorner seemed to appear about the width of the and height from the side of the canvas when ever moved. See example below :
I have been to the StackOverflow question here about using a grid splitter, but this will not work for me since controls will be overlapping grid columns.
I also have been to a similar question, but the first answer does not work at all, and the second answer just merely points to a blog where the gentleman either works for microsoft and created the ResizingAdorner class or just copied the code from the wpf samples site. I have also tried is revised code here but with no luck.
Is there a quick fix i'm not seeing
发布评论
评论(1)
当更深入地研究代码时,我发现有一部分从所需的宽度和高度中减去了 x 和 y,即使我还没有拖动装饰器。所以我将示例中的以下代码更改
为以下代码:
我还没有遇到任何怪癖,但这似乎是正确的。
When looking into the code a little deeper, I found a portion that was subtracting the x and y from the desired width and height, even thought I wasn't dragging the adorner yet. so I changed the following code in their example :
to the following code:
I haven't experienced any quirks yet, but it seems right.