UWP win10 app 新关键字x:Bing
最后更新于:2022-04-01 20:22:37
原本使用MVVM开发,我们使用数据绑定是x:Binging
新的关键字x:Bing使用和原来x:Binging区别不大。
~~~
~~~
几乎没有什么改变
x:Bing的优点是
- 速度比x:Binging快
- 强类型
- 可以在编译找出类型不同的错误
### 绑定ViewModel
直接在MainPage.xaml.cs写入`viewModel view=new viewModel();`
在xaml
~~~
~~~
### 绑定方法
可以在ViewModel写一个方法,然后绑定到xaml
我们可以把常用通知属性写成一个类,给ViewModel继承

~~~
using System.ComponentModel;
namespace ViewModel
{
///
/// 提供继承通知UI改变值
///
public class notify_property : INotifyPropertyChanged
{
public notify_property()
{
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this , new PropertyChangedEventArgs(name));
}
}
}
}
~~~
ViewModel

PointerEntered方法,给Button绑定
xaml
~~~
~~~
在button的PointerEntered写{x:Bind view.Click}
点击成功到view.Click断点

参考:[http://www.cnblogs.com/tcjiaan/tag/Win10/](http://www.cnblogs.com/tcjiaan/tag/Win10/)
';