Win10开发5

Windows开发笔记5{MVVM模式}

17.实例:数据绑定与通知

对App.xaml中xaml代码解释:

<Application

    x:Class="数据绑定与通知.App"

   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:local="using:数据绑定与通知"

    RequestedTheme="Light">

 

</Application>

 

类比一下

Class Person

{}

Class Student :Person

{}

 

Student stu=new Student(); 这句等价于:

<Person

x:Class="命名空间.Student"

x:Name="stu"

…. >

 

18.使用静态资源

<Application

    x:Class="数据绑定与通知.App"

   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:local="using:数据绑定与通知"

    RequestedTheme="Light">

    <Application.Resource>

//标签中的Resource标签表示的是一个静态的资源对象,如果代码中或标签中使用一个东西,而且这个东西只需创建一次,那么就可以写在这里//

    </Application.Resource>

</Application>

 

19.实现使用静态资源,前台和后台的数据类型转换

   功能:如后台用m表示男,f表示女,在前台用汉字表示男女

->添加一个相应的转换类,这个类继承一个接口IValueConverter;

  这个接口提供两个方法:

  1)Convert:从后台转到前台

  2)ConvertBack:从前台转到后台

->Application.xaml中添加<Application.Resource></Application.Resource>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值