zoukankan      html  css  js  c++  java
  • Xamarin.Forms之Button

    为什么要讲Button,不管是何种UI系统,Button始终是一种很最常见的控件,但是Forms中得Button在使用的过程是出现了一些问题,特此记录一下

    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 简单封装resultMap返回对象为map
    freemarker 遍历树形菜单
    python 正则表达式
    python BeautifulSoup基本用法
    sublime中正则替换
    媒体查询
    响应式网站的优点和缺点
    响应式网站概念
    vue系列之vue-resource
    vue系列之项目打包以及优化(最新版)
  • 原文地址:https://www.cnblogs.com/yz1311/p/5578598.html
Copyright © 2011-2022 走看看