当前位置:网站首页>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
边栏推荐
- Apache Doris Community PMC Yang Zhengguo: How do open source projects strike a balance between their own and the community's needs?
- 记一次 .NET 某工控自动化控制系统 卡死分析
- 传统数据中台又贵又复杂?何不试一试永久免费的下一代数据中台
- 重谈联想5G编码投票事件
- 程序员的专属浪漫——用3D Engine 5分钟实现烟花绽放效果
- 《ABP Framework 极速开发》 - 教程首发
- 【机器学习】回归树生成过程及举例理解
- International Soil Modeling Consortium-ISMC
- QoS - ROS2 principle 9 】 【 deadline, activity and life
- crm系统哪家好?好用的crm管理系统推荐
猜你喜欢
不安装运行时运行 .NET 程序
AlphaControls 控件 TsPanel TsGroupBox 块与组的结合
一口气拿下6个大厂offer,是什么水平
逻辑越权和水平垂直越权支付篡改,验证码绕过,接口
WinForm(三)揭开可视化控件的面纱
基于ABP和Magicodes实现Excel导出操作
Logic unauthorized and horizontal and vertical unauthorized payment tampering, verification code bypass, interface
How to choose a good SaaS knowledge base tool?
[Pycharm easy to use function]
好的架构是进化来的,不是设计来的
随机推荐
动态RDLC报表(五)
十七、一起学习Lua 错误处理
mysql生成随机姓名、手机号、日期
Discuz! Forum program installation + template configuration tutorial
A carnival of art and technology, cloud XR supports Anaya 2022 Sandbox Immersive Art Season
leetcode300.最长递增子序列(动态规划)
JVM内存模型和结构详解(五大模型图解)
leetcode/链表中环的入口节点
Problems Existing in Hardware Development of Electronic Products
Logic unauthorized and horizontal and vertical unauthorized payment tampering, verification code bypass, interface
如何在 PC 机上测试移动端的网页?
动手学深度学习_风格迁移
crm系统哪家好?好用的crm管理系统推荐
An in-depth understanding of the implementation principle of Hybrid
【机器学习】回归树生成过程及举例理解
CPU状态信息us,sy,ni,id,wa,hi,si,st含义
Redis 定长队列的探索和实践
ABP 6.0.0-rc.1的新特性
What platform is EPIC?
面试中老生常谈的MySQL问答集锦夯实基础