Reputation: 3790
I´m creating a smal WPF-Application with 5 Tabs and I´m wondering if it´s a good idea to seperate the tabs into UserControls. I think it is nice because my XAML-Code is about 400 alines and grows but at the other side i think it´s much work to pass the events to my main window and slows it down. Maybe i could work with the events at the UserControls but then I need solutions to have access to variables in my main window.
So what would you recommend me?
Upvotes: 1
Views: 86
Reputation: 6651
As Ed S. said above, it will definitely not slow your app down. I would recommend you to separate into distinct user controls. More than the XAML weight loss, it will really help you understanding easily your architecture. My personal approach would be "One tab = one UserControl = one ViewModel". I have developed some big applications in WPF, now I can look at them and instantaneously understand what's going on in there, since all parts are separated
Upvotes: 0
Reputation: 124692
It really depends on how simple your application is and how resilient to change it needs to be. If this is a throw away app then no, you don't need to split things out into user controls, but it may make your life a bit easier. We can't tell you what you should do because we don't know your requirements, but creating a user control will definitely make your code easier to change in the future (or during development even) if needed.
Since you mentioned that this is a relatively small app, use this as a general rule; the moment that managing the controls in each tab becomes a problem, wrap them in a UserControl.
but at the other side i think it´s much work to pass the events to my main window and slows it down.
It's not a lot of work and it definitely isn't going to cause performance problems.
Upvotes: 2