编辑
2023-12-14
软件编程
0

警告

此文内容暂时不要参考,只是测试使用。

在Xaml中添加StackLayout,其中包含了一个ListView。

右侧写js是因为写成xmal没有代码提醒

js
<StackLayout> <!-- Place new controls here --> <Label Text="设备列表" HorizontalOptions="Center" VerticalOptions="Start" FontSize="Large"/> <ListView x:Name="listView" ItemSelected="OnItemSelected" IsPullToRefreshEnabled="true" RefreshCommand="PullToRefresh" HasUnevenRows="true" VerticalOptions="Start" HorizontalOptions="FillAndExpand" > <!--Header="{Binding Intro}"--> <!--Footer="{Binding Summary}" --> <ListView.ItemTemplate> <DataTemplate> <ViewCell > <StackLayout Padding="5,5,5,5" BackgroundColor="#000000" HorizontalOptions="FillAndExpand" Orientation="Horizontal"> <StackLayout Padding="10,10,10,10" BackgroundColor="#AFEEEE" HorizontalOptions="FillAndExpand" Orientation="Horizontal"> <StackLayout Padding="5,5,0,0" HorizontalOptions="Start" VerticalOptions="Start" Orientation="Vertical"> <Label Text="Name :" VerticalTextAlignment="Center" FontSize="Medium" /> <Label Text="Exname :" VerticalTextAlignment="Start" FontSize="Medium" /> <Label Text="Classname :" VerticalTextAlignment="Center" FontSize="Medium" /> <Label Text="State :" VerticalTextAlignment="Start" FontSize="Medium" /> <Label Text="DATATime :" VerticalTextAlignment="Start" FontSize="Medium" /> </StackLayout> <StackLayout Padding="0,5,0,0" HorizontalOptions="Start" VerticalOptions="Start" Orientation="Vertical"> <Label Text="{Binding Name}" VerticalTextAlignment="Center" FontSize="Medium" /> <Label Text="{Binding Exname}" VerticalTextAlignment="Center" FontSize="Medium" /> <Label Text="{Binding Classname}" VerticalTextAlignment="Center" FontSize="Medium" /> <Label Text="{Binding State}" VerticalTextAlignment="Center" FontSize="Medium" /> <Label Text="{Binding DataTime}" VerticalTextAlignment="Center" FontSize="Medium" /> </StackLayout> </StackLayout> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout>

添加两个类

C#
class DriveList { public ObservableCollection<Drivedetel> Driveitemlist { get; set; } } public class Drivedetel { public string Name { get; set; } public string Exname { get; set; } public string DataTime { get; set; } public string State { get; set; } public string Classname { get; set; } }

本文作者:Kellermen

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!