将 ScrollViewer 附加到 FrameworkElement?
是否可以使用Adorner
或其他方式动态获取UIElement/FrameworkElement
并将其放置在动态创建的ScrollViwer
中?我知道明显的问题是您必须首先将元素与其父元素分离,但我正在寻找一种优雅的方法来执行此操作。
Is it possible, using an Adorner
or other means, to dynamically take a UIElement/FrameworkElement
and place it within a dynamically created ScrollViwer
? I know that the obvious problem will be that you have to detach the element from it's parent element first, but I am looking for an elegant way of doing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的元素不必是交互式的,您可以只使用
VisualBrush
。如果它实际上必须从一个地方移动到另一个地方并继续照常工作,您将必须复制您的控件或附加/分离它。据我所知,没有“优雅”的方法可以做到这一点 - 您必须通过正常的方式,例如
Children.Remove/Add
(如果其父级是面板)等。If your element doesn't have to be interactive you can just use a
VisualBrush
. If it has to actually move from one place to the other and keep working as usual you'll have to either duplicate your control or attach/detach it.To my knowledge there's no "elegant" way of doing this - you'll have to go through normal means, such as
Children.Remove/Add
(if its parent is a panel), etc.