Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

A resource with the key 'Xamarin.Forms.StackLayout' is already present in the ResourceDictionary

$
0
0

Hello everyone, I am getting the following Exception:
System.ArgumentException: A resource with the key 'Xamarin.Forms.StackLayout' is already present in the ResourceDictionary.

Because of this code in my App.xaml ResourceDictionary:

<Application.Resources>
        <ResourceDictionary>
            <!-- omitted irrelevant parts -->

            <Style TargetType="StackLayout" x:Key="VerticalStack">
                <Setter Property="Orientation" Value="Vertical"/>
                <Setter Property="Spacing" Value="16"/>
            </Style>

            <Style x:Name="FormFirstPortraitStyle" TargetType="StackLayout" BasedOn="{StaticResource VerticalStack}">
                <Setter Property="HorizontalOptions" Value="Center"/>
                <Setter Property="VerticalOptions" Value="Start"/>
                <Setter Property="Margin" Value="16, 100, 16, 16"/>
            </Style>

            <Style x:Name="FormFirstLandscapeStyle" TargetType="StackLayout" BasedOn="{StaticResource VerticalStack}">
                <Setter Property="HorizontalOptions" Value="Center"/>
                <Setter Property="VerticalOptions" Value="Center"/>
                <Setter Property="Margin" Value="16, 16, 16, 16"/>
            </Style>
        </ResourceDictionary>
    </Application.Resources>

If I remove the "FormFirstLandscapeStyle" style, it works.
I am setting the TargetType to StackLayout, not the key... I think I am doing something wrong, but I cannot figure out what...
Thanks for helping.


Viewing all articles
Browse latest Browse all 204402

Trending Articles