• 章节:26
  • 访问:707
  • 时长:00:05:22
  • 日期:2020-01-07 10:13

批量的方式获取用户,呈现到界面上面。

增加一个类

     public class UserDetailPatch
    {
        public List<UserDetail> user_info_list { set; get; }
    }

反序列化

var dyc = JsonHelper.DeserializeJson<UserDetailPatch>(res);
this.userDetails.ItemsSource = dyc.user_info_list;

调整xaml界面 去掉宽高 修改头像高度

<Page x:Class="WeixinManager.PageUserManage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="MainWindow">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
            <StackPanel Grid.Row="0" VerticalAlignment="Center">
                <Button Content="获取用户列表" Width="150" HorizontalAlignment="Left" Height="50" Click="Button_Click"/>
            </StackPanel>
        <DataGrid Grid.Row="1" Name="userDetails" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding nickname}" Header="昵称"></DataGridTextColumn>
                <DataGridTextColumn Binding="{Binding sex}" Header="性别"></DataGridTextColumn>
                <DataGridTextColumn Binding="{Binding city}" Header="城市"></DataGridTextColumn>
                <DataGridTextColumn Binding="{Binding headimgurl}" Visibility="Hidden" Header="头像">
                    
                </DataGridTextColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.Header>
                        <Label>头像</Label>
                    </DataGridTemplateColumn.Header>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding bitmapImageHead}" Height="50"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Binding="{Binding groupid}" Header="分组ID"></DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Page>

clipboard.png