Xamarin.Forms之Button
2016-06-12 19:42
281 查看
为什么要讲Button,不管是何种UI系统,Button始终是一种很最常见的控件,但是Forms中得Button在使用的过程是出现了一些问题,特此记录一下
1.IsEnabled属性
即使设置了Button得背景色,当IsEnabled="false"的时候,背景色会变成灰色,文字也是会变成灰色
2.IsEnable属性无效的问题
的确有人遇到过这个问题,直接设置IsEnabled="false",Button居然该是可以点击,这就是一个BUG,截止到v2.2版本,Forms依旧没有解决
改问题的原因是Command与IsEnabled冲突导致的,如果在Xaml中Command放在IsEnabled的后面,则会出现上面的问题
目前有两种解决方法:
1).在Command中,设置CanExecute直接返回绑定的signIsEnabled,
这样在isSignEnabled直接设置为false的时候,也是有效的
2).在XAML中,将IsEnabled放在Command的后面,就一切OK了
1.IsEnabled属性
即使设置了Button得背景色,当IsEnabled="false"的时候,背景色会变成灰色,文字也是会变成灰色
2.IsEnable属性无效的问题
的确有人遇到过这个问题,直接设置IsEnabled="false",Button居然该是可以点击,这就是一个BUG,截止到v2.2版本,Forms依旧没有解决
改问题的原因是Command与IsEnabled冲突导致的,如果在Xaml中Command放在IsEnabled的后面,则会出现上面的问题
<Button Grid.Column="2" Text="点我" IsEnabled="{Binding signIsEnabled}" Command="{Binding SignMessage}" Style="{StaticResource DialogButtonStyle}"/>
目前有两种解决方法:
1).在Command中,设置CanExecute直接返回绑定的signIsEnabled,
new Command(()=>{},()=>isSignEnabled);
这样在isSignEnabled直接设置为false的时候,也是有效的
2).在XAML中,将IsEnabled放在Command的后面,就一切OK了
<Button Grid.Column="2" Text="点我" Command="{Binding SignMessage}" IsEnabled="{Binding signIsEnabled}" Style="{StaticResource DialogButtonStyle}"/>
相关文章推荐
- 搭建java开发环境+配置tomcat+使用eclipse
- HTML最新标准HTML5小结
- 请移步本人新博客
- github常见操作和常见错误!
- 优秀程序员的生活品质
- What is DNS?
- 从VB来看-排序
- CSS文字样式
- 第十六周--阅读程序
- Myeclipse导入java文件后乱码
- iOS系统音频
- java对象流与序列化
- Struts2中获取session、request、respsonse的两种方法
- Unity 发布到Android的注意事项开发环境
- Bits and Bytes
- iptables
- HBase详细概述
- 将中文标点符号替换成英文标点符号
- Cookie禁用了,Session还能用吗?
- OpenGL深入探索——点光源中的法向量计算