• 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}"/>
    

      

  • 相关阅读:
    temp etc/hosts
    chrome 32位安装好没法访问解决命令 64位也会有这样的问题
    函数与存储过程的区别
    VS创建新的本地数据库
    主从同步
    自定义函数Function
    特殊存储过程——触发器Trigger
    存储过程Procedure
    工具:sql server profiler(分析器)
    数据表访问
  • 原文地址:https://www.cnblogs.com/yz1311/p/5578598.html
Copyright © 2020-2023  润新知