简体   繁体   English

如果父网格/面板不再可见,如何删除文本框的Adorner

[英]How to remove Adorner of a TextBox if the Parent Grid / Panel is not visible anymore

I have "made my own" TextBox with some Adorners. 我已经用一些装饰器“制作了自己的”文本框。

The first Adorner will display the "Title" in it if .Text value is empty. 如果.Text值为空,则第一个Adorner将在其中显示“标题”。

The second will highlight the border red if the input is wrong.. 如果输入错误,第二个将突出显示红色边框。

Works well, but now i have the case that MyTextBox is within a Grid which will be invisible from start up .. instead of a "create new dialog" i make this grid visible as an "popup" within the mainwindow .. works well too! 工作正常,但现在我的情况是MyTextBox在一个网格中,该网格从启动时将是不可见的。而不是“创建新对话框”,我将此网格显示为主窗口中的“弹出窗口”。 !

but if i collapse this Grid, the adorner will stay there .. 但是,如果我折叠此网格,装饰器将留在那里。

how can the TextBox see that it's parent panel is not visible anymore?? TextBox如何看到它的父面板不再可见?

Maybe you iterate through the VisualTree using the VisualTreeHelper.getParent() -Method. 也许您可以使用VisualTreeHelper.getParent()- Method遍历VisualTree。

If you found your Grid, listen to it´s IsVisibleChanged-Event. 如果找到了网格,请收听其IsVisibleChanged-Event。

Greetigns 问候语

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM