Creating an instance of a nested class in XAML

后端 未结 3 955
攒了一身酷
攒了一身酷 2020-11-27 17:37

in a XAML file (a WPF UserControl), is there a way to reference an inner class \"B\" defined in another class \"A\" ?

publi         


        
3条回答
  •  攒了一身酷
    2020-11-27 18:23

    I was searching and searching, because if this is possible, I would like to know. Unfortunately, I found this on msdn:

    Your custom class must not be a nested class. Nested classes and the "dot" in their general CLR usage syntax interfere with other WPF and/or XAML features such as attached properties.

    So, it appears you can't reference a nested class with the dot operator. As for alternative ways of getting to that inner class through XAML, I haven't had any luck in my searches yet. :o( But this is a rather interesting issue, so I will continue searching. Maybe I'll find some luck! :o)

提交回复
热议问题