简体   繁体   中英

Add specific to a generic xaml usercontrol

I have a UserControl (and background ViewModel) that I use across multiple projects - it's quite generic. Inevitably, in one project I have to modify it slightly to show an extra command (preferably as an extra button in the grids context menu, but if need be just an extra button). How can I implement this but keep the class generic?

edit : I'm aware of patterns like dependency injection in C#, but when it comes to xaml I don't know how to proceed. So as well as specific ways to accomplish this I'm also after possible design options.

If more details are required let me know.

Thanks

Hi Create another partial class and add new functionality to it.And add the refernece of assembly of this partial class functionality only where you want this new functionality . I hope this will give you an idea.

To have some form of reuse I broke down the generic xaml page into usercontrols, built a specific xaml page and referenced the generic usercontrols where possible. It's not what I wanted to do, but it's better than a completely new xaml page for every instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM