WPF Prism - Where to put Resources?

后端 未结 3 638
死守一世寂寞
死守一世寂寞 2021-02-01 22:15

I have a prism application and various modules. I am wondering where is the best place to locate resources such as styles, brush, controltemplates, datatemplates?

Should

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 22:53

    Application-wide resources I usually put in a ResourceDictionary, which is added to either App.xaml or StartupWindow.xaml

    Resources for a specific View are usually located with the View. For example, a UserControl that is being used for a CalendarView will contain any custom resources for the Calendar, such as calendar-specific brushes, styles, templates, etc.

    I usually don't see a reason to make module-wide resources, but if I ever do I'd have a ResourceDictionary for the Module which can be loaded into the app's merged dictionaries at runtime, or included in individual Views in the Module.

提交回复
热议问题