WPF - FindName Returns null when it should not

后端 未结 8 704
-上瘾入骨i
-上瘾入骨i 2020-12-09 07:48

FindName is broken for me :(

The object I am looking for is there. I have proof.

Here is the scenario:

ToggleButton button = (ToggleButton)s         


        
8条回答
  •  离开以前
    2020-12-09 08:37

    I would suggest to avoid using FindName function, based on my experience, expecially problematic when you try to find something in the DataTemplate applied to some control. Instead , if it possible (based on your software architecture) declare Popup in XAML and refer to it like resource or use Binding to set some Model property to it's reference. Good luck.

提交回复
热议问题