Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: What are the advantages/disadvantages of using WPF UserControl? [closed]

I just want to raise this question about WPF's User Control. I just started using this 'control' in my WPF applications, instead of 'adding' all my controls in one WPF window.

Anyways, would I get a faster process time if I use User Control? How about Dependency Properties? Can I still 'communicate' between my User Control and my WPF window?

What are your thoughts about it? Thanks in advance.

like image 414
abramlimpin Avatar asked Oct 28 '25 00:10

abramlimpin


1 Answers

UserControls should be used for reuse, but this is not the main reason to use them.

the main reason to use useControsl is to seperate different parts of your xaml, so that each part is in charge of one responsibility only. for example, if you would write VisualStudio, you would create the ToolBox in one userControl, the CodeEditor in another userControl, etc. this is mainly for SRP, or Single Responsibility Priniciple.

Reuse, or DRY (Don't Repeat Yourself) is important, but SRP is WAY more important.

As to communication - yes, you would use dependecy properties.

like image 165
Elad Katz Avatar answered Oct 30 '25 18:10

Elad Katz