daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Jan 17th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <local:CustomView x:Name="customView"  ColorPalette="{Binding Colors}"/>
  2.    
  3. public class CustomView : View
  4. {
  5.     public CustomView()
  6.     {
  7.  
  8.     }
  9.  
  10.     public static void OnColorsChanged(BindableObject bindable, object oldValue, object newValue)
  11.     {
  12.         // Some Code
  13.     }
  14.  
  15.     public static readonly BindableProperty ColorsPaletteProperty =
  16.         BindableProperty.Create("ColorPalette", typeof(IEnumerable<Color>), typeof(CustomView), new List<Color>(){ Color.FromRgb(0, 0, 0),
  17.             Color.FromRgb(251, 176, 59)}, BindingMode.Default, null, OnColorsChanged);
  18.  
  19.     public IEnumerable<Color> ColorPalette
  20.     {
  21.         get { return (IEnumerable<Color>)GetValue(ColorsPaletteProperty); }
  22.         set { SetValue(ColorsPaletteProperty, value); }
  23.     }
  24. }
  25.    
  26. //Binding using SetBinding is working where as {Binding Colors} in xaml is not working
  27.  
  28. customView.SetBinding<ViewModel>(CustomView.ColorsPaletteProperty, vm => vm.Colors);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top