Hi, I have had this trouble too, this is not a solution but a work around.
Just comment out LayerIDs param while developing, restore it and build before deploying to production.
<esri:Legend Map="{Binding ElementName=MyMap}"
LayerItemsMode="Flat"
/> <!--LayerIDs="Businesses, Community Facilities, Education, Base Map Layer"-->
Hope this helps.