gpt4 book ai didi

c# - 在 Windows 8 商店应用程序中显示 Azure 移动服务数据库中表中的所有记录 - C#

转载 作者:太空宇宙 更新时间:2023-11-03 16:02:30 25 4
gpt4 key购买 nike

这个问题可以概括为:如何显示表中具有特定 ID 的所有记录? (我将记录显示在正确的位置,但它们显示为类似于Folder.Folder.List的内容)

我一直在尝试显示包含特定 MonthYearID 字段的所有记录。

页面布局是分页,当您单击 ListView 中的一个项目(从一月到十二月)时,屏幕的后半部分应该显示该数据库中的所有条目我自己放入的另一个 ListView 中的月份和年份。 (用户可以选择他们想要的年份,这将与他们在 ListView 中选择的月份组合起来组成monthYearID)

我拥有它,以便在选择适当的月份和年份时显示正确的条目,但不是显示记录,而是显示记录的引用(?)。

我只想显示记录的日期、时间和标题字段,所以这就是我所拥有的:

        private async void GetJournalEntries()
{
items = await JournalEntries.Where(journalEntries => journalEntries.MonthYearID == monthYearID).ToListAsync();

List<Data> list = new List<Data>();

for(int i = 0; i < items.Count; i++)
{
int x = items[i].Day;
string a = x.ToString();
string b = items[i].Time;
string c = items[i].Title;

list.Add(new Data(a, b, c));
}

//List<Data> list = new List<Data>();

//List<journalEntries> result = items.FindAll(s => );

//List<Data> list = new List<Data>();

//Find a way of displaying just the date, time and entry title

entryList.ItemsSource = list ;
}

正如您在评论中看到的,我尝试过的不同事情留下了一堆东西。上面的 block 开始为:

        private async void GetJournalEntries()
{
items = await JournalEntries.Where(journalEntries => journalEntries.MonthYearID == monthYearID).ToListAsync();

//Find a way of displaying just the date, time and entry title

entryList.ItemsSource = items;
}

我知道我的另一位队友能够做到

var currentUser = login.FirstOrDefault();

无论她使用什么,但这不适用于需要显示多条记录的情况。

我只是不知道该用什么来代替,而且已经到了我们无法继续我们的项目的地步 - 截止日期是明天。

如果我遗漏了任何内容,请告诉我。

谢谢!

最佳答案

显示引用是因为您提供了包含复杂对象(而不是简单字符串)的列表。

  1. 在这种情况下,您应该声明一个 ItemTemplate,在其中指定应使用复杂对象中的哪些属性 - 在您的情况下为“时间”和“标题”。

    <ItemsControl x:Name="entryList">
    <ItemsControl.ItemTemplate>
    <DataTemplate>
    <Grid>
    <TextBlock Text="{Binding Time}"/>
    <TextBlock Text="{Binding Title}"/>
    </Grid>
    </DataTemplate>
    </ItemsControl.ItemTemplate>
    </ItemsControl>
  2. 另一种解决方案是提供字符串列表作为数据源;以下是更改组成列表的代码的方法:

    List<String> list = new List<String>();

    for(int i = 0; i < items.Count; i++)
    {
    int x = items[i].Day;
    string a = x.ToString();
    string b = items[i].Time;
    string c = items[i].Title;

    //here whatever format you want..
    list.Add(a + " " + b + " " + c));
    }

关于c# - 在 Windows 8 商店应用程序中显示 Azure 移动服务数据库中表中的所有记录 - C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20689065/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com