【发布时间】:2018-03-29 19:26:48
【问题描述】:
我正在使用 xamarin 表单开发移动应用程序,在“user_page”中,我在 ListView 中显示了用户的最后一个订单,并且我添加了选择特定订单以获取更多信息的可能性。
这是我的 xaml 代码:
<ListView x:Name="Wash_list">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Clicked="OnMore"
CommandParameter="{Binding .}"
Text="More Info" />
<MenuItem Clicked="OnQR"
CommandParameter="{Binding .}"
Text="QR_Code" />
<!--IsDestructive="True"-->
</ViewCell.ContextActions>
<StackLayout Padding="15,0">
<Label Text="{Binding washType}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
这是我的 C# 代码(我被困在上面了..):
async public void OnMore(object sender, EventArgs e)
{
int i = 0;
HttpClient _Client = new HttpClient();
var content = await _Client.GetStringAsync(urlTrade);
var get = JsonConvert.DeserializeObject<List<WashBuyData>>(content);
var mi = ((MenuItem)sender);
for (i = 0; i <= get.Count ; i++)
if (true)
await DisplayAlert("About " + mi.CommandParameter, "Buy on: " + get[i].timestamp, "OK");
}
所以...我想做的是显示所选项目的特定信息,我该怎么做? 我试图从所选项目中选择文本值或 id 来设置我的“i”参数,但没有成功......
【问题讨论】:
标签: android xamarin xamarin.forms