User Control vs WPF Management Template

I recently looked at someone’s code and came across a user control whose interface looks like this screenshot

enter image description here

This control has no code in its code behind the file, I think we could move all the xaml code of this user control into a control template and use it anyway. I want to know if this is good practice and should I do it?

Do they have any advantage in the performance and design of one approach over another?

+4
source share
2 answers

I want to know if this is a good practice.

So, first we need to identify good practice? I will give a flexible point of view of good practice: do it only if you need it. So the answer to your question is for you:

use it as required

Is it required elsewhere? If so, use a control pattern. If not, use User Control, which will be more readable for the next developer anyway (Keep It Stupid and Simple).

+1
source

Since this will ultimately be UserCotrol, now suppose some other team working on another module needs this control, and they want to load the Datagrid event into this control. Now, if you create it as a datagrid in a usercontrol, then they can easily access and subscribe to this datagrid. If you do this in a ControlTemplate, then it will be difficult, if not impossible.

+1
source

All Articles