首页 > 解决方案 > 使用 C# for UI 而不是 xml 在 Xamarin 中处理应用程序的资源?

问题描述

我正在使用 C# 为我的 UI 在 xamarin.forms 中编写一个应用程序。但是,我很难找到任何资源来帮助我处理严格使用 c# 而不是 c# 和 xml 的某些事情(例如数据绑定)。如果有人能指出我可以找到那些资源(如果存在的话)的方向,那就太棒了。(PS 是的,我已经用谷歌搜索了我能想到的每一种方式,但是您使用的所有关键字(例如 xamarin + c# + UI 等)总是使用 xml 不断返回更多结果)

标签: c#xamarin.forms

解决方案


Xamarin绑定文档在 C# 和 XAML 中有示例

// set the binding context for the page
this.BindingContext = new MyViewModel();

// create a label 
Label myLabel = new Label();

// set the binding to a property on the VM
myLabel.SetBinding(Label.TextProperty, "Description");

推荐阅读