C# MAUI ListView ,模仿微信版本更新
page.xaml
<ListView ItemsSource="{x:Static local:VersionUpdateModel.All}"
RowHeight="{StaticResource rowHeight}"
ItemSelected="OnListViewItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="15, 5, 0, 5"
Orientation="Horizontal"
Spacing="240">
<StackLayout Padding="5, 0, 0, 0"
VerticalOptions="Center">
//标题
<Label Text="{Binding Title}"
FontAttributes="Bold"
FontSize="16" />
//时间
<StackLayout Orientation="Horizontal"
Spacing="0">
<Label Text="{Binding Description,
StringFormat='{0:X2}'}" />
</StackLayout>
</StackLayout>
//箭头
<Label FontFamily="icon"
Grid.Column="2"
FontSize="16"
FontAttributes="Bold"
HorizontalOptions="End"
HorizontalTextAlignment="Center"
Text=""
TextColor="Black"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
page.xaml.cs
private async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs args)
{
(sender as ListView).SelectedItem = null;
if (args.SelectedItem != null)
{
VersionUpdateModel pageData = args.SelectedItem as VersionUpdateModel;
Page page = (Page)Activator.CreateInstance(pageData.Type);//获取路径
Application.Current.MainPage.Navigation.PushModalAsync(page);//跳转
}
}
model.
public class VersionUpdateModel
{
public VersionUpdateModel(Type type, string title, string description)
{
Type = type;
Title = title;
Description = description;
}
public Type Type { private set; get; }
public string Title { private set; get; }
public string Description { private set; get; }
static VersionUpdateModel()
{
All = new List<VersionUpdateModel>
{
new VersionUpdateModel(typeof(VersionContentPage), " 8.2.1 主要更新",
"2022-9-21"),
new VersionUpdateModel(typeof(VersionContentPage), " 8.2.2 主要更新",
"2022-9-22"),
new VersionUpdateModel(typeof(VersionContentPage), " 8.2.3 主要更新",
"2022-9-23"),
new VersionUpdateModel(typeof(VersionContentPage), " 8.2.4 主要更新",
"2022-9-28"),
};
}
public static IList<VersionUpdateModel> All { private set; get; }
}
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhihfbci
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
excel图片置于文字下方的方法
PHP中文网 06-27 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
微信提示登录环境异常是什么意思原因
PHP中文网 04-09 -
微信运动停用后别人还能看到步数吗
PHP中文网 07-22 -
微信人名旁边有个图标有什么用
PHP中文网 03-11