zoukankan      html  css  js  c++  java
  • lightswitch conditional formatting change color

    BTW, the best way to do a conditional color setting in LS beta 2 is to use the new SetBinding method. 

    For example:

          Me.FindControl("MyControl").SetBinding(TextBox.BackgroundProperty, "Value", New ColorConverter(), BindingMode.OneWay)
    
      Public Class ColorConverter
        Implements IValueConverter
    
        Public Function Convert(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
          If CType(value, Integer) > 20 Then
            Return New SolidColorBrush(Colors.Orange)
          End If
          Return New SolidColorBrush(Colors.Yellow)
        End Function
    
        Public Function ConvertBack(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
    
          Throw New NotImplementedException()
        End Function
      End Class
    
    
     

    This will assign the background color to Orange when the value is great than 20.  With this code, we don't have to write extra code to monitor when the value is changed, and change the color again.

  • 相关阅读:
    Java操作数据库——使用JDBC连接数据库
    MySQL入门——Linux下安装后的配置文件
    Linux上搭建SVN服务
    PHP包管理工具composer
    收藏博文
    Linux上软件安装
    nginx配置详解
    Linux文本编辑器Vim使用
    Linux常用命令整理
    Linux增加swap空间
  • 原文地址:https://www.cnblogs.com/neozhu/p/2199041.html
Copyright © 2011-2022 走看看