also if you are toggling groups:
MgLayerGroupCollection mgLayerGroup = Map.GetLayerGroups();
MgLayerGroup nameGroup = mgLayerGroup.GetItem("name") as MgLayerGroup;
if (nameGroup.GetVisible() == true)
{
nameGroup.SetVisible(false);
}
else
{
nameGroup.SetVisible(true);
}