实例介绍
什么是Comet? Comet是一种编写跨平台UI的现代方式。基于.NET MAUI,它遵循了Model View Update (MVU)模式,并为您提供了神奇的数据绑定功能!
关键概念
Comet基于MVU架构:
- View是一个屏幕。视图具有一个Body方法,您可以通过使用属性[Body]来分配它:
public class MyPage : View { [Body] View body () => new Text("Hello World"); }
或者手动从您的构造函数中:
public class MyPage : View { public MyPage() { Body = body; } View body () => new Text("Hello World"); }
热重新加载
使用热重新加载是开发用户界面的最快方法。
设置简单,只需要几个步骤:
- 从Releases中安装Visual Studio扩展Comet.Reload(或者如果您使用Visual Studio Code,则安装.NET Mobile的Comet)
- 在NuGet上安装Comet项目模板。
- 将这个简短的代码片段添加到您的AppDelegate.cs和/或MainActivity.cs,或者等价的位置。
【实例截图】
【核心代码】
文件清单
└── Comet-6a9a120c65153af9306a2757aaa353e923187428
├── art
│ ├── CometLogo.ai
│ ├── mvu-pattern.png
│ └── mvvm-pattern.png
├── build
│ ├── Comet-Nuget.sln
│ ├── Comet-Tests.sln
│ ├── DotNet
│ │ ├── Dependencies
│ │ │ ├── Directory.Build.props
│ │ │ ├── Directory.Build.targets
│ │ │ ├── Environment.Build.props
│ │ │ ├── Packs.csproj
│ │ │ ├── Versions.props
│ │ │ └── Workloads.csproj
│ │ ├── Directory.Build.props
│ │ ├── DotNet.csproj
│ │ └── NuGet.config
│ ├── install-vs.ps1
│ ├── MauiVersionUpdater
│ │ ├── MauiVersionUpdater.csproj
│ │ └── Program.cs
│ ├── package-github.yml
│ └── package-nuget.yml
├── CODE-OF-CONDUCT.md
├── Comet.Debug.sln
├── Comet.nuspec
├── Comet.Reload.nuspec
├── Comet.Skia.nuspec
├── Comet.sln
├── Comet.sln.DotSettings
├── Directory.Build.targets
├── External
│ └── Maui
├── LICENSE
├── README.md
├── sample
│ └── Comet.Sample
│ ├── ApiAudit
│ │ └── ApiAuditManager.cs
│ ├── Comet.Sample.csproj
│ ├── CommunityQuestions
│ │ ├── Question1a.cs
│ │ ├── Question1b.cs
│ │ ├── Question1c.cs
│ │ ├── Question1.cs
│ │ ├── Question1d.cs
│ │ └── Question1e.cs
│ ├── Comparisons
│ │ ├── Section1.cs
│ │ ├── Section2.cs
│ │ ├── Section3.cs
│ │ ├── Section4b.cs
│ │ ├── Section4c.cs
│ │ ├── Section4.cs
│ │ └── Section5.cs
│ ├── GitHubIssues
│ │ ├── Issue123.cs
│ │ ├── Issue125b.cs
│ │ ├── Issue125c.cs
│ │ ├── Issue125.cs
│ │ ├── Issue133b.cs
│ │ ├── Issue133c.cs
│ │ └── Issue133.cs
│ ├── GlobalUsings.cs
│ ├── Graphics
│ │ ├── BindableFingerPaint.cs
│ │ ├── GraphicsSample5.cs
│ │ ├── GraphicsSample6.cs
│ │ ├── SimpleFingerPaint.cs
│ │ ├── SkiaButtonSample.cs
│ │ ├── SkiaSample1.cs
│ │ ├── SkiaSample2.cs
│ │ ├── SkiaSample3.cs
│ │ ├── SkiaSample3WithScrollview.cs
│ │ └── SkiaSample4.cs
│ ├── LiveStreamIssues
│ │ ├── DavidSample1a.cs
│ │ ├── DavidSample1b.cs
│ │ ├── DavidSample1c.cs
│ │ ├── DavidSample1.cs
│ │ └── DavidSample2.cs
│ ├── Models
│ │ └── Song.cs
│ ├── MyApp.cs
│ ├── Platforms
│ │ ├── Android
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── MainActivity.cs
│ │ │ ├── MainApplication.cs
│ │ │ └── Resources
│ │ │ └── values
│ │ │ └── colors.xml
│ │ ├── iOS
│ │ │ ├── AppDelegate.cs
│ │ │ ├── Info.plist
│ │ │ └── Program.cs
│ │ ├── MacCatalyst
│ │ │ ├── AppDelegate.cs
│ │ │ ├── Entitlements.Debug.plist
│ │ │ ├── Entitlements.Release.plist
│ │ │ ├── Info.plist
│ │ │ └── Program.cs
│ │ ├── Tizen
│ │ │ ├── Main.cs
│ │ │ └── tizen-manifest.xml
│ │ └── Windows
│ │ ├── app.manifest
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ └── Package.appxmanifest
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Reload.cs
│ ├── Resources
│ │ ├── AppIcon
│ │ │ ├── appiconfg.svg
│ │ │ └── appicon.svg
│ │ ├── appiconfg.svg
│ │ ├── appicon.svg
│ │ ├── Fonts
│ │ │ ├── OpenSans-Regular.ttf
│ │ │ └── OpenSans-Semibold.ttf
│ │ ├── Images
│ │ │ ├── dotnet_bot.svg
│ │ │ └── turtlerock.jpg
│ │ ├── Raw
│ │ │ └── AboutAssets.txt
│ │ ├── Splash
│ │ │ └── splash.svg
│ │ └── Styles
│ │ ├── Colors.xaml
│ │ └── Styles.xaml
│ └── Views
│ ├── AnimationSample.cs
│ ├── AuditReportPage.cs
│ ├── BasicNavigationTestView.cs
│ ├── BasicTestView.cs
│ ├── BindingSample.cs
│ ├── ButtonSample1.cs
│ ├── ClipSample1.cs
│ ├── ClipSample2.cs
│ ├── ClipSample_AspectFill.cs
│ ├── ClipSample_AspectFit.cs
│ ├── ClipSample_Fill.cs
│ ├── ClipSample_None.cs
│ ├── ContinuosSample.cs
│ ├── DatePickerSample.cs
│ ├── DemoCreditCardView2.cs
│ ├── DemoCreditCardView3.cs
│ ├── DemoCreditCardView.cs
│ ├── GridSample1.cs
│ ├── InsaneDiffPage.cs
│ ├── LabelSamples.cs
│ ├── ListViewDetails.cs
│ ├── ListViewSample1.cs
│ ├── ListViewSample2.cs
│ ├── MainPage.cs
│ ├── MaterialSample.cs
│ ├── MaterialStylePicker.cs
│ ├── MenuItem.cs
│ ├── NestedViews.cs
│ ├── ProgressBarSample1.cs
│ ├── RadioButtonSample.cs
│ ├── RideTheCometSample.cs
│ ├── SampleApp.cs
│ ├── SectionedListViewSample.cs
│ ├── SecureFieldSample1.cs
│ ├── SecureFieldSample2.cs
│ ├── SecureFieldSample3.cs
│ ├── SecureFieldSample4.cs
│ ├── ShapeSample1.cs
│ ├── ShapeSample2.cs
│ ├── ShapeViewSample.cs
│ ├── SkiaControlsSample.cs
│ ├── SliderSample1.cs
│ ├── StepperSample1.cs
│ ├── TabViewSample.cs
│ ├── TextFieldSample1.cs
│ ├── TextFieldSample2.cs
│ ├── TextFieldSample3.cs
│ ├── TextFieldSample4.cs
│ ├── TextStylesSample.cs
│ ├── TextWeightSample.cs
│ ├── VGridNumberPad.cs
│ ├── VGridSample.cs
│ ├── ViewLayoutTestCase.cs
│ ├── VirtualListViewSample.cs
│ ├── VirtualSectionedListViewSample.cs
│ └── VStackSample.cs
├── src
│ ├── Comet
│ │ ├── Alignment.cs
│ │ ├── Animations
│ │ │ ├── Animation.cs
│ │ │ ├── AnimationExtensions.cs
│ │ │ └── AnimationSequence.cs
│ │ ├── AppHostBuilderExtensions.cs
│ │ ├── Attributes.cs
│ │ ├── Binding.cs
│ │ ├── BindingObject.cs
│ │ ├── Comet.csproj
│ │ ├── Comet.debug.csproj
│ │ ├── Controls
│ │ │ ├── AbstractLayout.cs
│ │ │ ├── ContainerView.cs
│ │ │ ├── ContentView.cs
│ │ │ ├── ControlsGenerator.cs
│ │ │ ├── FlyoutNavigationView.cs
│ │ │ ├── GraphicsView.cs
│ │ │ ├── Grid.cs
│ │ │ ├── HGrid.cs
│ │ │ ├── HStack.cs
│ │ │ ├── IContainerView.cs
│ │ │ ├── IContentTypeHash.cs
│ │ │ ├── IControlState.cs
│ │ │ ├── ImageButton.cs
│ │ │ ├── Image.cs
│ │ │ ├── IThumbView.cs
│ │ │ ├── IViewWrapperView.cs
│ │ │ ├── LayoutEventArgs.cs
│ │ │ ├── ListView.cs
│ │ │ ├── ModalView.cs
│ │ │ ├── NavigationView.cs
│ │ │ ├── Orientation.cs
│ │ │ ├── RadioButton.cs
│ │ │ ├── RadioGroup.cs
│ │ │ ├── ResultView.cs
│ │ │ ├── ScrollView.cs
│ │ │ ├── ShapeView.cs
│ │ │ ├── Spacer.cs
│ │ │ ├── TabView.cs
│ │ │ ├── VGrid.cs
│ │ │ ├── View.cs
│ │ │ ├── VStack.cs
│ │ │ ├── WebView.cs
│ │ │ └── ZStack.cs
│ │ ├── EnvironmentAware.cs
│ │ ├── EnvironmentData.cs
│ │ ├── Exceptions
│ │ │ └── ReadonlyRequiresException.cs
│ │ ├── FrameConstraints.cs
│ │ ├── Gestures
│ │ │ ├── Gesture.cs
│ │ │ ├── IGestureView.cs
│ │ │ └── TapGesture.cs
│ │ ├── global.json
│ │ ├── GlobalUsings.cs
│ │ ├── Graphics
│ │ │ ├── AffineTransformF.cs
│ │ │ ├── DrawingStyle.cs
│ │ │ ├── Gradient.cs
│ │ │ ├── GraphicsOperations.cs
│ │ │ ├── IControlDelegate.cs
│ │ │ ├── IDrawableControl.cs
│ │ │ ├── LinearGradient.cs
│ │ │ ├── PathBuilder.cs
│ │ │ ├── PathF.cs
│ │ │ ├── PathOperation.cs
│ │ │ ├── RadialGradient.cs
│ │ │ └── Stop.cs
│ │ ├── Handlers
│ │ │ ├── ListView
│ │ │ │ ├── ListViewHandler.Android.cs
│ │ │ │ ├── ListViewHandler.cs
│ │ │ │ ├── ListViewHandler.iOS.cs
│ │ │ │ ├── ListViewHandler.Standard.cs
│ │ │ │ └── ListViewHandler.Windows.cs
│ │ │ ├── Navigation
│ │ │ │ ├── NavigationViewHandler.Android.cs
│ │ │ │ ├── NavigationViewHandler.cs
│ │ │ │ ├── NavigationViewHandler.iOS.cs
│ │ │ │ ├── NavigationViewHandler.Standard.cs
│ │ │ │ └── NavigationViewHandler.Windows.cs
│ │ │ ├── RadioButton
│ │ │ │ ├── RadioButtonHandler.Android.cs
│ │ │ │ ├── RadioButtonHandler.iOS.cs
│ │ │ │ ├── RadioGroupHandler.Android.cs
│ │ │ │ └── RadioGroupHandler.iOS.cs
│ │ │ ├── ScrollView
│ │ │ │ ├── ScrollViewHandler.Android.cs
│ │ │ │ ├── ScrollViewHandler.cs
│ │ │ │ ├── ScrollViewHandler.iOS.cs
│ │ │ │ ├── ScrollViewHandler.Standard.cs
│ │ │ │ └── ScrollViewHandler.Windows.cs
│ │ │ ├── ShapeView
│ │ │ │ ├── ShapeViewHandler.Android.cs
│ │ │ │ ├── ShapeViewHandler.cs
│ │ │ │ ├── ShapeViewHandler.iOS.cs
│ │ │ │ ├── ShapeViewHandler.Standard.cs
│ │ │ │ └── ShapeViewHandler.Windows.cs
│ │ │ ├── Spacer
│ │ │ │ └── SpacerHandler.cs
│ │ │ ├── TabView
│ │ │ │ ├── TabViewHandler.Android.cs
│ │ │ │ ├── TabViewHandler.cs
│ │ │ │ ├── TabViewHandler.iOS.cs
│ │ │ │ ├── TabViewHandler.Standard.cs
│ │ │ │ └── TabViewHandler.Windows.cs
│ │ │ └── View
│ │ │ ├── CometViewHandler.Android.cs
│ │ │ ├── CometViewHandler.cs
│ │ │ └── CometViewHandler.iOS.cs
│ │ ├── Helpers
│ │ │ ├── BaseExtensions.cs
│ │ │ ├── ColorExtensions.cs
│ │ │ ├── ControlsExtensions.cs
│ │ │ ├── DatabindingExtensions.cs
│ │ │ ├── DrawingExtensions.cs
│ │ │ ├── FixedSizeDictionary.cs
│ │ │ ├── FixedSizedQueue.cs
│ │ │ ├── FontExtensions.cs
│ │ │ ├── GraphicsExtensions.cs
│ │ │ ├── IDGenerator.cs
│ │ │ ├── LayoutExtensions.cs
│ │ │ ├── LineBreakModeExtensions.cs
│ │ │ ├── ListExtensions.cs
│ │ │ ├── MathExtensions.cs
│ │ │ ├── MauiExtensions.cs
│ │ │ ├── RectangleExtensions.cs
│ │ │ ├── StringExtensions.cs
│ │ │ ├── TabViewExtensions.cs
│ │ │ ├── TextExtensions.cs
│ │ │ ├── ThreadHelper.cs
│ │ │ ├── ViewExtensions.cs
│ │ │ └── WeakStack.cs
│ │ ├── ImageSources
│ │ │ └── ImageSources.cs
│ │ ├── Internal
│ │ │ ├── Extensions.cs
│ │ │ └── ReflectionExtensions.cs
│ │ ├── Layout
│ │ │ ├── GridConstraints.cs
│ │ │ ├── GridLayoutManager.cs
│ │ │ ├── HStackLayoutManager.cs
│ │ │ ├── VStackLayoutManager.cs
│ │ │ └── ZStackLayoutManager.cs
│ │ ├── Logger.cs
│ │ ├── Maui
│ │ │ ├── CometApp.cs
│ │ │ ├── CometWindow.cs
│ │ │ └── IMauiContextHolder.cs
│ │ ├── MulticastAction.cs
│ │ ├── Platform
│ │ │ ├── Android
│ │ │ │ ├── CometFragment.cs
│ │ │ │ ├── CometNavigationView.cs
│ │ │ │ ├── CometRecyclerViewAdapter.cs
│ │ │ │ ├── CometRecyclerView.cs
│ │ │ │ ├── CometRecyclerViewHolder.cs
│ │ │ │ ├── CometScrollView.cs
│ │ │ │ ├── CometTabView.cs
│ │ │ │ ├── CometTouchGesterListener.cs
│ │ │ │ ├── CometView.cs
│ │ │ │ ├── CustomFrameLayout.cs
│ │ │ │ ├── HandlerExtensions.cs
│ │ │ │ └── ModalManager.cs
│ │ │ ├── iOS
│ │ │ │ ├── CometViewController.cs
│ │ │ │ ├── CometView.cs
│ │ │ │ ├── CUIContainerView.cs
│ │ │ │ ├── CUINavigationController.cs
│ │ │ │ ├── CUIRadioButton.cs
│ │ │ │ ├── CUIScrollView.cs
│ │ │ │ ├── CUIShapeView.cs
│ │ │ │ ├── CUITableViewCell.cs
│ │ │ │ ├── CUITableView.cs
│ │ │ │ ├── CUITableViewSource.cs
│ │ │ │ ├── CUITabView.cs
│ │ │ │ ├── CUITapGestures.cs
│ │ │ │ ├── HandlerExtensions.cs
│ │ │ │ └── iOSExtensions.cs
│ │ │ ├── Standard
│ │ │ │ └── HandlerExtensions.cs
│ │ │ └── Windows
│ │ │ ├── HandlerExtensions.cs
│ │ │ └── ListCell.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── ServiceContainer.cs
│ │ ├── Shadow.cs
│ │ ├── Shapes
│ │ │ ├── Capsule.cs
│ │ │ ├── Circle.cs
│ │ │ ├── Ellipse.cs
│ │ │ ├── Path.cs
│ │ │ ├── PathScaling.cs
│ │ │ ├── Pill.cs
│ │ │ ├── Rectangle.cs
│ │ │ ├── RoundedRectangle.cs
│ │ │ ├── Shape.cs
│ │ │ └── Squircle.cs
│ │ ├── State.cs
│ │ ├── StateManager.cs
│ │ ├── Styles
│ │ │ ├── ButtonStyle.cs
│ │ │ ├── ControlState.cs
│ │ │ ├── Material
│ │ │ │ ├── ColorPalette.cs
│ │ │ │ ├── Extensions.cs
│ │ │ │ └── MaterialStyle.cs
│ │ │ ├── NavbarStyle.cs
│ │ │ ├── ProgressBarStyle.cs
│ │ │ ├── SliderStyle.cs
│ │ │ ├── StyleAwareValue.cs
│ │ │ ├── Style.cs
│ │ │ ├── StyleExtensions.cs
│ │ │ ├── StyleType.cs
│ │ │ ├── TextStyle.cs
│ │ │ └── ViewStyle.cs
│ │ └── TextStyle.cs
│ └── Comet.SourceGenerator
│ ├── AutoNotifyGenerator.cs
│ ├── Comet.SourceGenerator.csproj
│ ├── CometViewSourceGenerator.cs
│ ├── StateWrapperGenerator.cs
│ ├── StringExtensions.cs
│ └── ViewGeneratorData.cs
├── templates
│ ├── comet-templates.nuspec
│ └── single-project
│ ├── CometApp1
│ │ ├── App.cs
│ │ ├── CometApp1.csproj
│ │ ├── GlobalUsings.cs
│ │ ├── Helpers
│ │ │ └── Reload.cs
│ │ ├── MainPage.cs
│ │ ├── Platforms
│ │ │ ├── Android
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── MainActivity.cs
│ │ │ │ ├── MainApplication.cs
│ │ │ │ └── Resources
│ │ │ │ └── values
│ │ │ │ └── colors.xml
│ │ │ ├── iOS
│ │ │ │ ├── AppDelegate.cs
│ │ │ │ ├── Info.plist
│ │ │ │ ├── Program.cs
│ │ │ │ └── Resources
│ │ │ │ └── LaunchScreen.xib
│ │ │ ├── MacCatalyst
│ │ │ │ ├── AppDelegate.cs
│ │ │ │ ├── Info.plist
│ │ │ │ └── Program.cs
│ │ │ └── Windows
│ │ │ ├── app.manifest
│ │ │ ├── App.xaml
│ │ │ ├── App.xaml.cs
│ │ │ └── Package.appxmanifest
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ └── Resources
│ │ ├── appiconfg.svg
│ │ ├── appicon.svg
│ │ ├── Fonts
│ │ │ ├── OpenSans-Regular.ttf
│ │ │ └── OpenSans-Semibold.ttf
│ │ ├── Images
│ │ │ └── dotnet_bot.svg
│ │ └── Raw
│ │ └── AboutAssets.txt
│ └── CometApp1.sln
└── tests
├── Comet.Blazor.Tests
│ ├── Comet.Blazor.Tests.csproj
│ └── RegistrarTests.cs
└── Comet.Tests
├── Animations
│ ├── AnimationTests.cs
│ └── LerpTests.cs
├── AutoNotifyTest.cs
├── BindingTests.cs
├── Comet.Tests.csproj
├── EnvironmentTests.cs
├── GridTests.cs
├── Handlers
│ ├── GenericViewHandler.cs
│ ├── ProgressBarHandler.cs
│ ├── SecureFieldHandler.cs
│ ├── SliderHandler.cs
│ ├── TextFieldHandler.cs
│ └── TextHandler.cs
├── Helpers
│ └── ViewExtensions.cs
├── HotReloadTestsNoParameters.cs
├── HotReloadWithParameters.cs
├── HStackTests.cs
├── LayoutTests.cs
├── MapperTests.cs
├── ReloadTransfersStateTest.cs
├── StateBindingTests.cs
├── TestBase.cs
├── UI.cs
└── ViewTests.cs
88 directories, 409 files
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论