ViewModel manipulating it's View

Topics: Actions & Coroutines, Conventions, Getting Started
May 30, 2013 at 6:21 PM
Probably a stupid simple answer to this but how do I go about having my ViewModel manipulate it's View?

For instance, I have a Expander that I want to expand on a button click based on some criteria. That being, the button calls a method on the VM that pulls in a BindableCollection<>. If that collection has more than 1 element I want to expand the Expander Control.

Can someone point me in the right direction?
May 31, 2013 at 10:29 AM
Just a quick idea (I did not check it).

If you want to do that only using binding, you could set up a property in your VM like that :
public bool ShouldExpand { get { return (this._yourcollection.Count() > 0); } }
You should raise a changed event for this property whenever your collection is updated.
Then, in your XAML, you would bind the IsExpanded property of the expander to the previously mentionned ShouldExpand property.