Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 1.65 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why does the MultiBinding not work for CornerRadius
  2. <Border Background="Red" Width="100" Height="100"
  3.         CornerRadius="{Binding Converter={vc:SingleAndMultiConverter}}" />
  4. <Border Background="Red" Width="100" Height="100"
  5.         CornerRadius="{MultiBinding Converter={vc:SingleAndMultiConverter}}" />
  6.        
  7. public class SingleAndMultiConverter : MarkupExtension, IValueConverter, IMultiValueConverter
  8. {
  9.     public override object ProvideValue(IServiceProvider serviceProvider)
  10.     {
  11.         return this;
  12.     }
  13.  
  14.     public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  15.     {
  16.         return Convert();
  17.     }
  18.     public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  19.     {
  20.         return Convert();
  21.     }
  22.     private object Convert()
  23.     {
  24.         return 15;
  25.     }
  26.  
  27.     public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  28.     {
  29.         throw new NotSupportedException();
  30.     }
  31.     public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
  32.     {
  33.         throw new NotSupportedException();
  34.     }
  35. }
  36.        
  37. [ValueConversion(typeof(object[]),typeof(CornerRadius))]
  38. public class Multi : IMultiValueConverter
  39. {
  40.     public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  41.     {
  42.         return new CornerRadius(Double.Parse("15"));
  43.     }
  44.  
  45.     public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  46.     {
  47.         throw new NotImplementedException();
  48.     }
  49.  
  50. }