At version 4.0 , we don't have built-in Legend, but you can create a LegendAdornmentLayer to implement like that.
I attached a sample code which you can look at, it's just a sample that maybe nor perfect but can lead you to learn how to create your own legend. And the user code is like below: