Accessing a resource via codebehind in WPF

后端 未结 6 813
刺人心
刺人心 2020-12-01 07:06

I have a custom collection defined in my window resources as follows (in a Sketchflow app so the window is actually a UserControl):



        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 07:36

    If you want to access a resource from some other class (i.g. not a xaml codebehind), you can use

    Application.Current.Resources["resourceName"];
    

    from System.Windows namespace.

提交回复
热议问题