question

guessmeifucan-8050 avatar image
0 Votes"
guessmeifucan-8050 asked ·

Will App Performance reduces if we create many user controls ?

Will App Performance breaks if we create many user controls ( to reduce even small code redundancy in 2 or 3 xaml files) and also when creating many .xaml and .cs files ?

uwpuwp-xaml
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RichardZhang-MSFT avatar image
1 Vote"
RichardZhang-MSFT answered ·

Hello,​

Welcome to our Microsoft Q&A platform!

Creating a UserControl is to better achieve the reuse of code and controls, which has significant advantages in code maintenance.

Application performance does not depend on how many Xaml files you have created, but depends on how many controls are running in the application at the same time. So creating some UserControl files has no direct impact on application performance.

Thanks

· 4 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hai @RichardZhang-MSFT , Thanks for the reply. In my case i have a page which holds nearly 10 - 12 set of codes (mostly which repeats in different modules). So i decided to make each as a usercontrol and reuse it in different modules. My doubt is, some set of codes are only 10 lines of code but repeating in 2 or 3 module. in such case, is it recommended to create a new control or repeat such small code in each modules ?

0 Votes 0 · ·

Hi, If the code you are talking about is C # code, you can consider extracting it and creating a new static class as a global processing module. Other controls can call this method through this static class. If it's XAML code, yes, you can create another UserControl for reuse.

0 Votes 0 · ·

Im speaking about XAML code. If i create a new usercontrols for all the small redundant xaml codes, it results in running many controls at the same time. As u said earlier, will it affect the app performance ? If yes, then how will you say that creating the usercontrols in my case is a recommended one ? @RichardZhang-MSFT

0 Votes 0 · ·
Show more comments