本文介绍了如何继承画布的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个customInkCanvas,它继承自InkCanvas.

我有一张要放置在InkCanvas上的图像.

对于普通的InkCanvas,它可以起作用:

I have a customInkCanvas which inherits from InkCanvas.

I have an image that I wish to place on the InkCanvas.

For the normal InkCanvas, this works:

Canvas.SetTop(image, y);
Canvas.SetLeft(image, x);
InkCanvas.Children.Add(image);


但是,对于CustomInkCanvas,以上操作将失败.那么如何在CustomInkCanvas上放置元素?

我猜想Top,Left等是InkCanvas的附加属性,而不会传递给customInkCanvas.

任何帮助将不胜感激!

我已经意识到这实际上是一个两部分的问题:
1.我想念InkCanvas不能从Canvas继承,所以我需要用InkCanvas.SetTop()替换Canvas.SetTop().了解到这一点之后,有没有办法
2.继承还是传递附加的属性?

感谢


However, for CustomInkCanvas, the above fails. So how do I position an element on the CustomInkCanvas?

I''m guessing that Top,Left, etc, are attached properties to InkCanvas and are not passed down to customInkCanvas.

Any help will be really appreciated!

I''ve realized this is actually a two-part question:
1. I missed that InkCanvas does NOT inherit from Canvas, so I was needing to replace Canvas.SetTop() with InkCanvas.SetTop(). Having learned that, is there a way to
2. Inherit or pass-down attached properties?

Thanks

推荐答案

InkCanvas.SetTop(image, y);
InkCanvas.SetLeft(image, x);
InkCanvas.Children.Add(image);



变量xy附加到image,然后InkCanvas查看通过MeasureOverrideArrangeOverride的过程中的变量.这意味着,如果您的CustomInkCanvas没有覆盖InkCanvas中的那些方法,那么将不会观察到这些值.

希望这会有所帮助,
弗雷德里克(Fredrik)



The variables x and y are attached to image, and then InkCanvas looks at those during it''s MeasureOverride and ArrangeOverride passes. This means that if your CustomInkCanvas not overrides those methods from InkCanvas then the values are not observed.

Hope this helps,
Fredrik


这篇关于如何继承画布的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 21:12