using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; namespace Flyad7_WPF.Converters { public class IO2BinConverter : IValueConverter { #region IValueConverter 成员 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { UInt16 io = (UInt16)value; string str = System.Convert.ToString(io, 2); return str.PadLeft(16, '0'); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return System.Convert.ToUInt16((string)value, 2); } #endregion } }