MasterDetailPage Shadow on iOS

Download Sample Download the sample

This platform-specific controls whether the detail page of a MasterDetailPage has shadow applied to it, when revealing the master page. It's consumed in XAML by setting the MasterDetailPage.ApplyShadow bindable property to true:

<MasterDetailPage ...
                  xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
                  ios:MasterDetailPage.ApplyShadow="true">
    ...
</MasterDetailPage>

Alternatively, it can be consumed from C# using the fluent API:

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...

public class iOSMasterDetailPageCS : MasterDetailPage
{
    public iOSMasterDetailPageCS(ICommand restore)
    {
        On<iOS>().SetApplyShadow(true);
        // ...
    }
}

The MasterDetailPage.On<iOS> method specifies that this platform-specific will only run on iOS. The MasterDetailPage.SetApplyShadow method, in the Xamarin.Forms.PlatformConfiguration.iOSSpecific namespace, is used to control whether the detail page of a MasterDetailPage has shadow applied to it, when revealing the master page. In addition, the GetApplyShadow method can be used to determine whether shadow is applied to the detail page of a MasterDetailPage.

The result is that the detail page of a MasterDetailPage can have shadow applied to it, when revealing the master page:

Screenshot of a MasterDetailPage with and without shadow