微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

列表不显示项目

如何解决列表不显示项目

我在列表视图中显示项目时遇到问题。我试图添加Mode =双向,单向或认。

我已经检查了绑定

    "version": "0.2.0","configurations": [
        {
            "name": ".NET Core Launch (web)","type": "coreclr","request": "launch","prelaunchTask": "build",// If you have changed target frameworks,make sure to update the program path.
            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/firstproject.dll","args": [],"cwd": "${workspaceFolder}","stopAtEntry": false,// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-Webbrowser
            "serverReadyAction": {
                "action": "openExternally","pattern": "\\bNow listening on:\\s+(https?://\\S+)"
            },"env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },"sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        },{
            "name": ".NET Core Attach","request": "attach","processId": "${command:pickProcess}"
        }
    ]

我的页面的背面

  <ListView x:Name="list"  
                        HasUnevenRows="True" 
                        IsPullToRefreshEnabled="True"
                        HorizontalOptions="CenterandExpand" 
                        VerticalOptions="FillAndExpand"
                        VerticalScrollBarVisibility="Never"
                       
                        CachingStrategy="RecycleElement"
                        ItemsSource="{Binding DateFormatList}"
                        SeparatorVisibility="Default" >
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                   <Label Text="{Binding DateType}" TextColor="black" HorizontalOptions="Start" FontSize="14" HorizontalTextAlignment="Center"  ></Label>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>                                                           
    

视图模型中的我的Ctor

public DateSettings()
        {
            InitializeComponent();
            BindingContext = new CustomSettingsviewmodel();
        }

型号

 public List<DateFormat> DateFormatList { get; private set; }
public CustomSettingsviewmodel()
{
      
            DateFormatList = new List<DateFormat>();
            DateFormatList.Add(new DateFormat
            {
                DateType = "yy/dd/mm",});
}

解决方法

您只能绑定到公共属性

public class DateFormat
{
    public string DateType { get; set; }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。