2013-02-21 58 views
2

如何在自動調整爲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(); 
    } 
} 

回答

5

您可以嘗試返回Binding.DoNothing

綁定源屬性或轉換器可以返回Binding.DoNothing以指示綁定引擎不執行任何操作。例如,要指示綁定引擎不要將值傳輸到綁定目標,不要將Binding轉換爲PriorityBinding或不要使用FallBackValue或默認值。

+0

Binding.DoNothing;確實有效。謝謝 – dongx 2013-02-21 16:59:44

相關問題