41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows.Data;
|
|||
|
|
|
|||
|
|
namespace 垂直剖面动态观测系统.Converter
|
|||
|
|
{
|
|||
|
|
//转换器 继承接口IValueConverter
|
|||
|
|
public class GenderConverter : IValueConverter
|
|||
|
|
{
|
|||
|
|
//从model向view的转换
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="value">model绑定上面的原始值</param>
|
|||
|
|
/// <param name="targetType"></param>
|
|||
|
|
/// <param name="parameter">前端传进去的值</param>
|
|||
|
|
/// <param name="culture"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
if (value == null || parameter == null)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
//如果value是1 碰到的是1 就会返回true 如果碰到的是2 就返回false 就会在前端进行体现
|
|||
|
|
return value.ToString() == parameter.ToString();
|
|||
|
|
}
|
|||
|
|
//从view向model的转换
|
|||
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//在界面上的操作就会将数值返回给这个方法
|
|||
|
|
return parameter;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|