骑士Xamarin xaml。VisualStateManager中的 "字段Normal已经被声明"。

问题描述 投票:1回答:1

我正在使用Xamarin Forms 4.5.0.617,并希望使用VisualStateManager(https:/docs.microsoft.comen-usxamarinxamarin-formsuser-interfacevisual-state-manager。)来改变元素被禁用时的样式。为了将其应用到我的所有样式中,我必须多次使用x:Name="Normal "或 "Disabled "或 "Focused",但Rider (https:/www.jetbrains.comde-derider)说 错误应用程序运行正常(风格正在改变),但骑手的警告仍然很烦人。

我是不是做错了什么?

<?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>
xaml xamarin.forms rider visualstatemanager app.xaml
1个回答
1
投票

你没有做错任何事情。这是RiderReSharper确认的已知问题。我已经报告过了 此处.

我可以建议的是,你给这个问题加个赞,或者写个评论,这样他们就可以把问题升级并迅速解决。

© www.soinside.com 2019 - 2024. All rights reserved.