当前位置: 首页 > news >正文

郫县建设局网站离石网站建设公司

郫县建设局网站,离石网站建设公司,wordpress标签页,网站在哪设置关键词适用于初学者的 .NET MAUI | Microsoft Learn 记录微软Learn中用到的代码。文章比较粗糙#xff0c;大部分是项目代码粘贴。想详细学习的可到上面的链接学习#xff0c;代码可以从这里复制后直接运行。 练习中一共有两个页面#xff1a; 1、MainPage.xaml 用于添加列表中的… 适用于初学者的 .NET MAUI | Microsoft Learn 记录微软Learn中用到的代码。文章比较粗糙大部分是项目代码粘贴。想详细学习的可到上面的链接学习代码可以从这里复制后直接运行。 练习中一共有两个页面 1、MainPage.xaml 用于添加列表中的内容。主要功能有向列表中添加一项左滑删除该项点击该选项进入详情页面。 2、DetailPage.xaml 显示详细信息实际上显示的很少。返回主界面。 用到的MVVM包有 1、CommunityToolkit.Mvvm 接下来是MainPage.xaml代码 ?xml version1.0 encodingutf-8 ? ContentPage xmlnshttp://schemas.microsoft.com/dotnet/2021/mauixmlns:xhttp://schemas.microsoft.com/winfx/2009/xamlx:ClassMauiAppDemo1.MainPagexmlns:viewmodeclr-namespace:MauiAppDemo1.ViewModelx:DataTypeviewmode:MainViewModelGrid RowDefinitions100,Auto,*ColumnDefinitions.75*,.25*Padding10RowSpacing10ColumnSpacing10Image Grid.ColumnSpan2Sourcedotnet_bot.pngBackgroundwhite/Entry PlaceholderEnter taskText{Binding Text}Grid.Row1/Button TextAddCommand{Binding AddCommand}Grid.Row1Grid.Column1/CollectionView Grid.Row2 Grid.ColumnSpan2ItemsSource{Binding Items}SelectionModeNone!--CollectionView.ItemsSourcex:Array Type{x:Type x:String}x:StringApples/x:Stringx:StringBananas/x:Stringx:StringOranges/x:String/x:Array/CollectionView.ItemsSource--CollectionView.ItemTemplateDataTemplate x:DataType{x:Type x:String}SwipeViewSwipeView.RightItemsSwipeItems SwipeItem TextDeleteBackgroundColorRedCommand{Binding Source{RelativeSource AncestorType{x:Type viewmode:MainViewModel}},PathDeleteCommand}CommandParameter{Binding .}//SwipeItems/SwipeView.RightItemsGrid Padding0,5FrameFrame.GestureRecognizersTapGestureRecognizer Command{Binding Source{RelativeSource AncestorType{x:Type viewmode:MainViewModel}},PathTapCommand}CommandParameter{Binding .}//Frame.GestureRecognizersLabel Text{Binding .}FontSize24//Frame/Grid/SwipeView/DataTemplate/CollectionView.ItemTemplate/CollectionView/Grid/ContentPageusing MauiAppDemo1.ViewModel;namespace MauiAppDemo1;public partial class MainPage : ContentPage {int count 0;public MainPage(MainViewModel vm){InitializeComponent();BindingContext vm;}} using MauiAppDemo1.ViewModel;namespace MauiAppDemo1;public static class MauiProgram {public static MauiApp CreateMauiApp(){var builder MauiApp.CreateBuilder();builder.UseMauiAppApp().ConfigureFonts(fonts {fonts.AddFont(OpenSans-Regular.ttf, OpenSansRegular);fonts.AddFont(OpenSans-Semibold.ttf, OpenSansSemibold);});builder.Services.AddSingletonMainPage();builder.Services.AddSingletonMainViewModel();builder.Services.AddTransientDetailPage();builder.Services.AddSingletonDetailViewModel(); return builder.Build();} }namespace MauiAppDemo1;public partial class AppShell : Shell {public AppShell(){InitializeComponent();Routing.RegisterRoute(nameof(DetailPage),typeof(DetailPage));} }using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks;namespace MauiAppDemo1.ViewModel {/// summary/// CommunityToolkit.Mvvm/// /summarypublic partial class MainViewModel : ObservableObject{public MainViewModel(){items new ObservableCollectionstring();}[ObservableProperty]ObservableCollectionstring items;[ObservableProperty]string text;[RelayCommand]void Add(){if (string.IsNullOrWhiteSpace(Text)) return;items.Add(Text);Text string.Empty;}[RelayCommand]void Delete(string s){if (items.Contains(s)){items.Remove(s);}}[RelayCommand] async Task Tap(string s){await Shell.Current.GoToAsync(${nameof(DetailPage)}?Text{s});}}/// summary/// 基本写法/// /summary//public class MainViewModel : INotifyPropertyChanged//{// string text;// public string Text// {// get text;// set// {// textvalue;// OnPropertyChanged(nameof(Text));// }// }// public event PropertyChangedEventHandler PropertyChanged;// void OnPropertyChanged(string name)PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));//} }DetailPage.xaml ?xml version1.0 encodingutf-8 ? ContentPage xmlnshttp://schemas.microsoft.com/dotnet/2021/mauixmlns:xhttp://schemas.microsoft.com/winfx/2009/xamlx:ClassMauiAppDemo1.DetailPagexmlns:viewmodelclr-namespace:MauiAppDemo1.ViewModelx:DataTypeviewmodel:DetailViewModelTitleDetailPageVerticalStackLayout Padding20Label Text{Binding Text}FontSize25VerticalOptionsCenter HorizontalOptionsCenter /Button TextGo BackCommand{Binding GoBackCommand}//VerticalStackLayout /ContentPage using MauiAppDemo1.ViewModel;namespace MauiAppDemo1;public partial class DetailPage : ContentPage {public DetailPage(DetailViewModel vm){InitializeComponent();BindingContext vm;} } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input;namespace MauiAppDemo1.ViewModel {[QueryProperty(Text,Text)]public partial class DetailViewModel:ObservableObject{[ObservableProperty]string text;[RelayCommand]async Task GoBack(){await Shell.Current.GoToAsync(..);}} }
http://www.w-s-a.com/news/665987/

相关文章:

  • 赣州制作网站企业硬件开发用什么语言
  • 新网站如何被网站收录百度排名优化软件
  • html网站简易模板国内买机票的网站建设
  • 百度关键词分析工具百度seo排名软
  • 自己怎样做免费网站ueditor 上传wordpress
  • 深圳高端网站开发网站建设公司销售技巧
  • 网站建设的优势是什么意思可拖动网站
  • 建设什么企业网站网站微信认证
  • 网站开发的平台成都有哪些好玩的
  • 上海金瑞建设集团网站怎么创建免费网页
  • 柳州做网站设计的公司制作网站软件下载
  • 湖南seo网站开发苏州网络营销及网站推广
  • 如何发布自己做的网站郑州网站建设定制开发
  • 重庆网站商城宁波网络公司联系方式
  • 个人网站建设实验心得seo课程简介
  • 免费自助建站系统下载推广app网站
  • 用scala做的网站标题关键词优化技巧
  • 百度网站评级wordpress忘记admin
  • 建筑标准下载网站263企业邮箱 登陆
  • 旅游房地产网站建设德保网站建设
  • 网站高端建设wordpress订单系统
  • 建设网站成本增加网站备案
  • 行业网站建设方案百度云图片转wordpress
  • 如何建设网站推广平台营销客户管理软件
  • 网站制作南宁如何撰写一个网站规划建设方案
  • 建站网站和维护需要会什么杭州人防质监站网址
  • 唐山免费做网站莱芜吧贴吧最新消息
  • 韶关市建设工程造价网站网络营销的平台有哪些
  • 网站建设费大概多少钱成都网站建设低价
  • 做表格的网站东莞常平房价