44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
|
|
|
|
|
|
namespace MSDevTool.Converters
|
|
{
|
|
//用于文字粗体
|
|
internal class TypeValueConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
//if (value == null)
|
|
// return false;
|
|
//else
|
|
//{
|
|
// var type = value.GetType();
|
|
// return type.IsClass || (type.IsValueType && !type.IsEnum && !type.IsPrimitive);
|
|
//}
|
|
var row = value as DataGridRow;
|
|
if (row == null) return false;
|
|
|
|
// 获取所在行对应的数据项
|
|
//var row = FindVisualParent<DataGridRow>(cell);
|
|
if (row == null) return false;
|
|
var dataItem = row.DataContext;
|
|
if (dataItem is PropValueBase { PropValue: not null } prop)
|
|
{
|
|
var type = prop.PropValue.GetType();
|
|
return type.IsClass || (type.IsValueType && !type.IsEnum && !type.IsPrimitive); // 替换为目标类型判断
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|