C# 如何将从Azure移动服务检索到的数据动态绑定到GridView?
使用Azure移动服务从我的Azure SQL DB检索数据,我希望在我的员工gridview中显示这些数据 以下是我的XAML代码:C# 如何将从Azure移动服务检索到的数据动态绑定到GridView?,c#,azure,win-universal-app,C#,Azure,Win Universal App,使用Azure移动服务从我的Azure SQL DB检索数据,我希望在我的员工gridview中显示这些数据 以下是我的XAML代码: <GridView Name="Employees" SelectionMode="Single" Width="Auto" ItemContainerStyle="{StaticResource CustomGridViewItemStyle}" SelectionChanged="Employees_SelectionChanged">
<GridView Name="Employees" SelectionMode="Single" Width="Auto" ItemContainerStyle="{StaticResource CustomGridViewItemStyle}" SelectionChanged="Employees_SelectionChanged">
<GridViewItem Name="EmployeeNumber" HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto" Height="Auto" Margin="140,50,0,0">
<StackPanel Name="ProfilePicAndDetails" Width="Auto" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,10,10">
<Image Name="ProfilePic" Source="Assets/profilepic.png" Height="140" Width="140" HorizontalAlignment="Left" VerticalAlignment="Top"></Image>
<StackPanel Name="Details" HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto" Margin="40,-10,0,0" Orientation="Vertical">
<StackPanel Name="DisplayName" Orientation="Horizontal">
<TextBox Name="FirstName" FontSize="26" FontFamily="Segoe UI" IsReadOnly="True" Background="{x:Null}" Foreground="White" SelectionHighlightColor="{x:Null}" BorderBrush="{x:Null}"/>
<TextBox Name="LastName" FontSize="26" FontFamily="Segoe UI" Margin="-10,0,0,0" IsReadOnly="True" Background="{x:Null}" Foreground="White" SelectionHighlightColor="{x:Null}" BorderBrush="{x:Null}"/>
</StackPanel>
<TextBox Name="Login" FontSize="18" FontFamily="Segoe UI" IsReadOnly="True" Background="{x:Null}" Foreground="White" SelectionHighlightColor="{x:Null}" BorderBrush="{x:Null}"/>
<TextBox Name="Phone" FontSize="18" FontFamily="Segoe UI" IsReadOnly="True" Background="{x:Null}" Foreground="White" SelectionHighlightColor="{x:Null}" BorderBrush="{x:Null}"/>
<TextBox Name="Mail" FontSize="18" FontFamily="Segoe UI" IsReadOnly="True" Background="{x:Null}" Foreground="White" SelectionHighlightColor="{x:Null}" BorderBrush="{x:Null}"/>
<StackPanel Name="OtherDetails" Margin="-190,10,0,0">
<TextBox Name="Title" FontSize="18" FontFamily="Segoe UI" IsReadOnly="True" Background="{x:Null}" Foreground="White" SelectionHighlightColor="{x:Null}" BorderBrush="{x:Null}"/>
<TextBox Name="Department" FontSize="18" FontFamily="Segoe UI" IsReadOnly="True" Background="{x:Null}" Foreground="White" SelectionHighlightColor="{x:Null}" BorderBrush="{x:Null}"/>
<TextBox Name="Manager" FontSize="18" FontFamily="Segoe UI" IsReadOnly="True" Background="{x:Null}" Foreground="White" SelectionHighlightColor="{x:Null}" BorderBrush="{x:Null}"/>
</StackPanel>
</StackPanel>
</StackPanel>
</GridViewItem>
</GridView>
我的代码隐藏检索数据:
var GetEmployeesTable = App.MobileService.GetTable<GetEmployee>();
var FoundEmployees = await GetEmployeesTable.Where(g => g.givenName == GivenName && g.surname == SurName).ToListAsync();
var GetEmployeesTable=App.MobileService.GetTable();
var FoundEmployees=await GetEmployeesTable.Where(g=>g.givenName==givenName&&g.lasname==lasname.toListSync();
我的数据库中有9个字段:
givenName、姓氏、邮件、电话、职称、部门、经理姓名、域名、sAMAccountName
目标是通过以下方式绑定这些文件:
注意:我可以显示多个雇员(意味着要动态创建多个gridview项)。您必须在XAML代码中为Text属性指定绑定。你好像忘了这个: 例如:
丹尼尔,谢谢你。你的链接提供了一个很好的例子。我不知道我可以将数据作为集合检索并直接绑定到gridview。
<TextBox Name="FirstName" Text="{Binding givenName}"