Access a control from within a DataTemplate with its identifying name

前端 未结 3 1828
醉话见心
醉话见心 2020-12-10 22:14

In my WPF application I have a ComboBox control that is located inside a Grid Control. In XAML I am assigning a name to the ComboBox:



        
3条回答
  •  感动是毒
    2020-12-10 22:37

    You can't access controls that are part of a DataTemplate with their name.

    You can try to read about some workarounds for example

    • WPF - Find a Control from DataTemplate in WPF

    You can also have a look at the dozens of posts here on SO issuing this topic for example

    • here
    • here
    • here
    • here
    • here
    • here
    • here
    • here

提交回复
热议问题