Reputation: 1584
I am using MVVM pattern and have a scenario where I need to hide a control based on some functional logic.
I have two options to handle it.
I can create a boolean property on view model and bind this with corresponding control to handle visibility and this property gets set based on some functional logic.
I can use a DataTrigger on control to handle visibility on XAML itself which use same functional logic here. (This functional logic are easy to access on XAML)
Question - Which is the correct way to handle it in terms of performance and maintainability etc. in WPF?
Upvotes: 3
Views: 407
Reputation: 21863
just have a look at this
Is it better to use DataTrigger instead of a databinding?
Upvotes: 4
Reputation: 9476
I would say option 1: Say u want to snap on a Silverlight View. Then you don't have to go and create the trigger in the Silverlight View.
So the first option will be the best pattern according to MVVM.
Upvotes: 2