zoukankan      html  css  js  c++  java
  • wpf转换器

    方面进行转换绑定

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Windows.Data;
     6 
     7 namespace NetReform
     8 {
     9     [ValueConversion(typeof(string), typeof(string))]
    10     class ReadBtnBKConvert : IValueConverter
    11     {
    12         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    13         {
    14             string b = "000";
    15 
    16             string reValue = System.Convert.ToString(value);
    17             if (reValue == "green")
    18             {
    19                 b = "0";
    20             }
    21             else if (reValue == "yellow")
    22             {
    23                 b = "1";
    24             }           
    25             else if (reValue == "")
    26             {
    27                 b = "";
    28             }
    29             else
    30             {
    31                 b = "1";//其它为1
    32             }
    33             return b;
    34         }
    35 
    36         public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    37         {
    38             throw new NotImplementedException();
    39         }
    40     }
    41 }
  • 相关阅读:
    278.First Bad Version
    277. Find the Celebrity
    256.Paint House
    276. Paint Fence
    275. H-Index II
    274. H-Index
    273. Integer to English Words
    272. Closest Binary Search Tree Value II
    270. Closest Binary Search Tree Value
    271. Encode and Decode Strings
  • 原文地址:https://www.cnblogs.com/ants_double/p/5365012.html
Copyright © 2011-2022 走看看