using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; namespace NeuWPFTest; public class SizeConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { // 确保我们得到了两个double值 (ActualWidth, ActualHeight) if (values != null && values.Length == 2 && values[0] is double && values[1] is double) { double width = (double)values[0]; double height = (double)values[1]; // 返回着色器所需的 Size 对象 return new Size(width, height); } return new Size(0, 0); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }