| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Data;
- using Muchinfo.MTPClient.Data.Helper;
- namespace Muchinfo.MTPClient.Infrastructure.Converters
- {
- /// <summary>
- /// 涨跌幅转换为Visibility
- /// </summary>
- public class IncreaseValueToVisibilityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- if (value == null || parameter == null)
- {
- return Visibility.Collapsed;
- }
- decimal intValue;
- int intParameter;
- if (!decimal.TryParse(value.ToString(), out intValue))
- {
- intValue = 0;
- }
- if (!int.TryParse(parameter.ToString(), out intParameter))
- {
- intParameter = 0;
- }
- if (intValue == 0 || intParameter == 0) return Visibility.Collapsed;
- if (intValue > 0)
- {
- if (intParameter == 1) return Visibility.Visible;
- if (intParameter == 2) return Visibility.Collapsed;
- }
- else
- {
- if (intParameter == 1) return Visibility.Collapsed;
- if (intParameter == 2) return Visibility.Visible;
- }
- return Visibility.Collapsed;
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- return 0;
- }
- }
- }
|