Rider Xamarin xaml:"Field Normal is already declared" 来自 VisualStateManager

Rider Xamarin xaml: "Field Normal is already declared" from VisualStateManager

我正在使用 Xamarin Forms 4.5.0.617 并想使用 VisualStateManager (https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual-state-manager) to change the style if an element is disabled. To apply this to all my styles, I have to use the x:Name="Normal" or "Disabled" or "Focused" multiple times, but Rider (https://www.jetbrains.com/de-de/rider/) says error 应用程序运行正确(风格正在改变)但骑手的警告仍然很烦人。

我是不是做错了什么?

<?xml version="1.0" encoding="utf-8"?>

<Application
    x:Class="ProjectApp.App"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:components="clr-namespace:Project.Components"
    xmlns:converters="clr-namespace:Project.Converters"
    xmlns:helpers="clr-namespace:Project.Helpers"
    xmlns:iconize="clr-namespace:Plugin.Iconize;assembly=Plugin.Iconize">

    <Application.Resources>
        <ResourceDictionary>

            <!--  Text  -->
            <Style
                x:Key="Label"
                TargetType="Label">
                <Setter
                    Property="VisualStateManager.VisualStateGroups">
                    <VisualStateGroupList>
                        <VisualStateGroup>
                            <VisualState
                                x:Name="Normal">
                                <VisualState.Setters>
                                    <Setter
                                        Property="TextColor"
                                        Value="Black" />
                                </VisualState.Setters>
                            </VisualState>
                            <VisualState
                                x:Name="Disabled">
                                <VisualState.Setters>
                                    <Setter
                                        Property="TextColor"
                                        Value="Gray" />
                                </VisualState.Setters>
                            </VisualState>
                            <VisualState
                                x:Name="Focused">
                                <VisualState.Setters>
                                    <Setter
                                        Property="TextColor"
                                        Value="{StaticResource Primary}" />
                                </VisualState.Setters>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateGroupList>
                </Setter>
            </Style>

            <!--  Picker  -->
            <Style
                x:Key="Picker"
                TargetType="Picker">
                <Setter
                    Property="FontSize"
                    Value="14" />
                <Setter
                    Property="TextColor"
                    Value="Black" />
                <Setter
                    Property="VerticalOptions"
                    Value="Center" />
                <Setter
                    Property="VisualStateManager.VisualStateGroups">
                    <VisualStateGroupList>
                        <VisualStateGroup>
                            <VisualState
                                x:Name="Normal">
                                <VisualState.Setters>
                                    <Setter
                                        Property="TextColor"
                                        Value="Black" />
                                </VisualState.Setters>
                            </VisualState>
                            <VisualState
                                x:Name="Disabled">
                                <VisualState.Setters>
                                    <Setter
                                        Property="TextColor"
                                        Value="Gray" />
                                </VisualState.Setters>
                            </VisualState>
                            <VisualState
                                x:Name="Focused">
                                <VisualState.Setters>
                                    <Setter
                                        Property="TextColor"
                                        Value="{StaticResource Primary}" />
                                </VisualState.Setters>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateGroupList>
                </Setter>
            </Style>

        </ResourceDictionary>
    </Application.Resources>
</Application>

你没有做错任何事。这是 Rider/ReSharper 的已确认已知问题。我已经举报了 here.

我能建议的是,你给这个问题投赞成票and/or写评论,这样他们就可以升级它并迅速解决它。