c# - 使用 C# for UI 而不是 xml 在 Xamarin 中处理应用程序的资源?
问题描述
我正在使用 C# 为我的 UI 在 xamarin.forms 中编写一个应用程序。但是,我很难找到任何资源来帮助我处理严格使用 c# 而不是 c# 和 xml 的某些事情(例如数据绑定)。如果有人能指出我可以找到那些资源(如果存在的话)的方向,那就太棒了。(PS 是的,我已经用谷歌搜索了我能想到的每一种方式,但是您使用的所有关键字(例如 xamarin + c# + UI 等)总是使用 xml 不断返回更多结果)
解决方案
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");
推荐阅读
- fhir-server-for-azure - 使用 client_credentials 身份验证流程时出现 401
- amazon-web-services - Ansible - 使用 NFS 在 Windows Server 2019 上挂载 Amazon EFS 文件系统:网络错误 53
- sql - Druid SQL 按日期分组
- python - 从其他脚本导入的变量只显示初始值
- java - 如何使用事务回栈来弹出片段?
- python - 超过某个时间点时的通知(Python)
- ios - iOS Core Data:仅保存背景上下文就足够了吗?为什么或者为什么不?
- javascript - JavaScript:推送嵌套对象键值对
- powershell - 在 Invoke-Command 的 ScriptBlock 中重定向 Import-Module 的输出
- r - 在R中的数组列表上使用表