WPF ViewBox blocks VisualTreeHelper search

混江龙づ霸主 提交于 2019-12-11 15:17:02

问题


I have tried this Navigation Service approach (View First) for MVVM-Light WPF https://stackoverflow.com/a/28968560/5272185

I realized that the VisualTreeHelper search for the Frame element does not find the Frame if the Frame is located inside a ViewBox.

Is there a good explanation of such strange behaviour? Is it possible to work around it?


回答1:


It turned out that the example code in the link was the problem. If you run into this type of problem I recommend to read the following from Josh Smith Understanding the Visual Tree and Logical Tree in WPF

The code he provides in the Research Tool project successfully found the ContentControl also when it is inside a ViewBox. I modified his code to return the content control. Problem solved.



来源:https://stackoverflow.com/questions/51948365/wpf-viewbox-blocks-visualtreehelper-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!