问题描述
我在列表视图中显示项目时遇到问题。我试图添加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; }
}