标签:c style class blog code java
xmlns:cmlib="clr-namespace:CommonLib;assembly=CommonLib"> <UserControl.Resources> <cmlib:CustomMultiValueConvertor x:Key="MultiValueConverter"/> </UserControl.Resources> <TextBlock Foreground="#FF7F7F7F" FontSize="22" IsHyphenationEnabled="True" > <TextBlock.Text> <MultiBinding Converter="{StaticResource MultiValueConverter}"> <Binding Path="OraElevatorData.shangyuegongzuorigonglvmidu" /> <Binding Path="OraElevatorData.benyuegongzuorigonglvmidu" /> </MultiBinding> </TextBlock.Text> </TextBlock>
public class CustomMultiValueConvertor : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { if ((double)values[0] == 0) { return "--"; } else { double bianhua = Math.Abs(((double)values[1] - (double)values[0]) / (double)values[0]); string result = (bianhua * 100).ToString("0") + "%"; return result; } } catch(Exception) { return "--"; } } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { return (value as string).Split(‘ ‘); } }
标签:c style class blog code java
原文地址:http://www.cnblogs.com/infly123/p/3765608.html