正如标题所述,我正在尝试将Azure“EasyTable”中的数据绑定到UWP应用程序中的界面。在调试时,我似乎只是获取表中项目的路径? This is what is output during debugging只有一个条目被绑定到“items”,这显然是从上面的输出中显示的内容。不确定如何从Azure中的表中提取实际条目。表名是“Event”,应用程序连接到数据库就好了。我一直在尝试在Azure文档中关注This guide,但没有成功。
任何帮助将不胜感激!
谢谢!
C#代码:
IMobileServiceTable<Event> eventTable = App.MobileService.GetTable<Event>();
IMobileServiceTable untypedEventTable = App.MobileService.GetTable("events");
// MobileServiceCollection<Event, Event> items;
public class Event
{
public string ID { get; set; }
public bool deleted { get; set; }
public string name { get; set; }
public string location { get; set; }
public string date { get; set; }
public string description { get; set; }
}
private async Task RefreshEvents()
{
MobileServiceInvalidOperationException exception = null;
try
{
List<Event> items = await eventTable
.Where(Event => Event.deleted == false)
.ToListAsync();
IEnumerable itemsControl = items;
ListItems.ItemsSource = items;
}
catch (MobileServiceInvalidOperationException e)
{
exception = e;
}
if (exception != null)
{
await new MessageDialog(exception.Message, "Error loading items").ShowAsync();
}
}
private async void btnRefresh_Click(object sender, RoutedEventArgs e)
{
await RefreshEvents();
}
}
XAML代码:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button x:Name="btnRefresh" Content="Refresh Results" HorizontalAlignment="Left" Margin="213,150,0,0" VerticalAlignment="Top" Height="39" Width="137" Click="btnRefresh_Click"/>
<ListView x:Name="ListItems" HorizontalAlignment="Left" Height="436" Margin="10,194,0,0" VerticalAlignment="Top" Width="340"/>
</Grid>