WPF装饰者状态和生命周期? [英] WPF adorner state and lifetime?

查看:89
本文介绍了WPF装饰者状态和生命周期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遇到装饰器(WPF)的一些问题.我注意到我的自定义装饰器有时可能会消失(我发现装饰器层中没有与我的控件相关联的装饰器),并且装饰器层本身有时可以 被关闭(启动WPF应用程序,然后将Remote Desktop插入该计算机,用于我的控件的装饰层不再是正在使用的装饰层,并且我的控件失去了装饰器.)

I'm running into some issues with an adorner (WPF).  I've noticed that my custom adorner can sometimes just disappear (I find that there is no adorner in the adorner layer that is linked to my control) and that the adorner layer itself can sometimes be switched out (start a WPF app and then Remote Desktop into that machine and the adorner layer that was in use for my control is no longer the one in use - and my control loses its adorner).

因此,我一直在考虑装饰器和装饰器层的体系结构,并认为也许它们被设计为系统可以随意破坏的短暂事物.  如果是这样,我找不到任何地方的文档.我找不到 关于装饰者或装饰者生命周期的任何信息都可以表明这一点,但是我看到的问题似乎支持这一点.  如果可以在各个地方消除装饰物,建议使用哪种方法来确保根据需要重新创建装饰物.并且, 然后编写没有状态/属性的装饰器似乎是明智的,因为可以随时将新的装饰器附加到控件上.我什至没有在文档中看到此提示-这很奇怪,因为MS通常描述生存期和状态管理 问题,如果它们是相关的.  所以,也许我只是遇到了bug?  任何见识将不胜感激.

So, I've been contemplating the architecture of adorners and adorner layers and think maybe they were designed to be transient things that the system could destroy at will.  If so, this is not documented anywhere that I can find.  I can't find any info on the lifetime of adorners or adornerlayers that would indicate this but the issues I'm seeing seem to support it.  If adorners can be wiped out at various points, what is the recommended way to ensure they are re-created as needed.  Also, it would seem wise then to write adorners with no state/properties as a new one could be attached to a control at any moment.  I don't even see hints of this in the documentation - which would be odd as MS typically describes lifetime and state management issues if they are relevant.  So, maybe I'm just running into bugs?  Any insight would be appreciated.

推荐答案

TBrummel,

Hi TBrummel,

谢谢您在这里发布.

由于您的问题与有关 WPF 论坛,我将把箱子移到那里.

Since your issue is related to WPF forum, I will move the case to there.

我希望你能理解我.

最好的问候,

Hart


这篇关于WPF装饰者状态和生命周期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆