当前位置:网站首页>win10 uwp 绑定静态属性
win10 uwp 绑定静态属性
2022-08-09 16:53:00 【林德熙】
Jasoon 大神问,如何绑定静态属性。 我们经常有静态属性,那么我们如何绑定
假如我们的ViewModel有一个静态属性
public static string CVTE
{
set;
get;
} = "lindexi";
一个方法是在xaml.cs写一个属性,get为静态属性。
public string Property => ViewModel.ViewModel.CVTE;
在xaml绑定xaml.cs属性
<TextBlock Text="{x:Bind Property,Mode=OneWay}"></TextBlock>
下面方法我没测试成功,但是有大神说他这样做是可以。
在需要绑定的类上写[Bindable]
这样写的具体参见:http://www.jaylee.org/post/2012/03/07/Xaml-integration-with-WinRT-and-the-IXamlMetadataProvider-interface.aspx
我不知道为何这样,知道的大神可以告诉我不?
然后在xaml写
xmlns:view="using:Bproperty.ViewModel"
<TextBlock Text="{x:Bind Path=(view:ViewModel.CVTE) }"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
参见:http://stackoverflow.com/questions/15854708/how-can-i-bind-a-xaml-property-to-a-static-variable-in-another-class
http://stackoverflow.com/questions/34701255/how-to-bind-to-attached-property-in-uwp
边栏推荐
- AlphaControls 控件 TsPanel TsGroupBox 块与组的结合
- 动态RDLC报表(四)
- 【解决】虚拟机VMware通过局域网连接机器人no route to host
- .NET MAUI 跨平台应用开发 I|.NET MAUI 跨平台基础
- 艺术与科技的狂欢,云端XR支撑阿那亚2022砂之盒沉浸艺术季
- How to adjust futures account opening process and handling fee
- 怎样选择一个好的SaaS知识库工具?
- 为了高性能、超大规模的模型训练,这个组合“出道”了
- The difference between approach and method
- leetcode/链表中环的入口节点
猜你喜欢
MySQL的索引你了解吗
WinForm(四)一种实现登录的方式
《.NET物联网从零开始》系列
【.NET6+Modbus】Modbus TCP协议解析、仿真环境以及基于.NET实现基础通信
【时序数据库InfluxDB】Windows环境下配置InfluxDB+数据可视化,以及使用 C#进行简单操作的代码实例...
Account opening requirements and exemptions for special futures such as crude oil
一键生成 API 文档的妙招
What is control board custom development?
我不写单元测试,被批了
[Pycharm easy to use function]
随机推荐
leetcode300.最长递增子序列(动态规划)
Account opening requirements and exemptions for special futures such as crude oil
手写flexible.js的原理实现,我终于明白移动端多端适配
WinForm(四)一种实现登录的方式
Lagrange interpolation formula matlab implementation
《ABP Framework 极速开发》 - 教程首发
Logic unauthorized and horizontal and vertical unauthorized payment tampering, verification code bypass, interface
怎样选择一个好的SaaS知识库工具?
本机号码一键登录原理
如何仿造一个websocket请求?
MySQL索引的B+树到底有多高?
.NET 6学习笔记(4)——解决VS2022中Nullable警告
JVM:(八)运行时数据区之方法区
浅谈如何保证Mysql主从一致
Self-taught software testing, how far can I go out to find a job?
mysql generates random name, mobile number, date
以技术御风险,护航云原生 | 同创永益 X 博云举办产品联合发布会
【解决】虚拟机VMware通过局域网连接机器人no route to host
搭建Zabbix监控系统
一口气拿下6个大厂offer,是什么水平