In MVVM if you would like to hide and show user controls you need to set up 2 properties.
public bool IsFirstVisible {get; set;}
public bool IsSecondVisible {get; set;}
public void OnTileClick()
{
if (IsFirstVisble)
{
IsSecondVisible = true;
IsFirstVisible = false;
}
else
{
IsSecondVisible = false;
IsFirstVisible = true;
}
}
Now, on your tile click, you will toggle the visibility on which user control is being shown. Next you need to reflect this on the xaml with a BoolToVisibility Converter like so.
<window.resources>
<booleantovisibilityconverter x:key="boolToVis" />
</window.resources>
<local:firstusercontrol visibility="{Binding IsFirstVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter = {StaticResource boolToVis}}" />
<local:secondusercontrol visibility="{Binding IsSecondVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter = {StaticResource boolToVis}}" />;
This should reflect a visible state when the property is true, and a collapsed state when the property is false.