gpt4 book ai didi

c# - 如何在某些情况下禁用转换器

转载 作者:行者123 更新时间:2023-12-02 05:13:30 24 4
gpt4 key购买 nike

autosize 为 false 时如何禁用以下转换器。我应该将什么代码放入什么都不做区域。

[ValueConversion(typeof(Boolean), typeof(Double))]
public class ConvertAutoSize2HeightWidth : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Boolean autosize = (Boolean)value;
if (autosize)
return Double.NaN;
else
//**do nothing**
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

最佳答案

可以尝试返回Binding.DoNothing .

A binding source property or a converter can return Binding.DoNothing to instruct the binding engine not to perform any action. For example, to instruct the binding engine not to transfer a value to the binding target, not to move to the next Binding in a PriorityBinding, or not to use the FallBackValue or default value.

关于c# - 如何在某些情况下禁用转换器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15007152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com