添加项目文件。
This commit is contained in:
27
UIShare/Converters/LessThanConverter.cs
Normal file
27
UIShare/Converters/LessThanConverter.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace UIShare.Converters // 确保命名空间跟你项目一致
|
||||
{
|
||||
public class LessThanConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is double actualWidth && parameter != null)
|
||||
{
|
||||
if (double.TryParse(parameter.ToString(), out double targetWidth))
|
||||
{
|
||||
// 如果实际宽度 小于 设定的阈值(比如600),返回 True
|
||||
return actualWidth < targetWidth;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user