Steve
Steve

Reputation: 1694

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

Upvotes: 1

Views: 190

Answers (2)

Steve
Steve

Reputation: 1694

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.

Upvotes: 0

yo chauhan
yo chauhan

Reputation: 12315

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.

Upvotes: 1

Related Questions