我正在尝试列出sql数据库中的一些数据,但是当我向上(或向下)滚动列表时,数据混杂在一起,数据是固定的,但位置不同,如果我单击该项目,它将自动更改最重要的价值...
这是我的Interactions.xaml代码
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="OficinaDigitalX.Views.Interactions"
xmlns:local="clr-namespace:OficinaDigitalX">
<ContentPage.BindingContext>
<local:ViewModel.CarInteractions/>
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout>
<ListView ItemsSource="{Binding Path=InteractionsList, Mode=TwoWay}">
<ListView.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="110"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Label Text="Fatura" FontSize="Medium" TextColor="Black" FontFamily="Bold" Grid.Column="0" Grid.Row="0" />
<Label Text="Intervenção" FontSize="Medium" TextColor="Black" Grid.Column="1" Grid.Row="0"/>
<Label Text="Total" FontSize="Medium" TextColor="Black" Grid.Column="2" Grid.Row="0"/>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="110"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0" Text="{Binding Invoice}"
TextColor="#f35e20" FontSize="10"/>
<Label Grid.Column="1" Grid.Row="0" Text="{Binding Article}"
TextColor="#503026" FontSize="10" />
<Label Grid.Column="2" Grid.Row="0" Text="{Binding Total,StringFormat='{0} €'}"
TextColor="#503026" FontSize="10" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
这是我的Interactions.xaml.cs代码
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Interactions : ContentPage
{
public Interactions (CarInfo car)
{
InitializeComponent();
BindingContext = new CarInteractions(car.VehicleId);
}
public Interactions()
{
}
}
}
CarInteractions(car.VehicleId)返回一个列表,该列表显示在listView上
这是我的CarInteractions.cs文件
public class CarInteractions : ViewModelBase
{
private List<InteractionsInfo> _InteractionsList;
public List<InteractionsInfo> InteractionsList
{
get
{
return _InteractionsList;
}
set
{
_InteractionsList = value;
OnPropertyChanged("InteractionsList");
}
}
public CarInteractions(int id)
{
GetFirstInteractionRow(id);
}
public CarInteractions() { }
public void GetFirstInteractionRow(int id)
{
string command = "(**not important**)";
string requestUriString = $"{MainPage.server}{command}/{id}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUriString);
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
using (var responseString = new StreamReader(response.GetResponseStream()))
{
InteractionsList = JsonConvert.DeserializeObject<ObservableCollection<InteractionsInfo>>(responseString.ReadToEnd());
}
}
catch (WebException ex)
{
using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream()))
{
}
throw;
}
}
}
答案 0 :(得分:1)
我遇到了最近发布的XF版本3.5的一些问题,建议您暂时将XF版本回滚到3.4,直到解决这些错误为止。
答案 1 :(得分:0)
我也是,但是现在我更新到了新的FX,效果很好。