diff options
Diffstat (limited to 'Xamarin.Forms.ControlGallery.iOS')
-rw-r--r-- | Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs | 34 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj | 2 |
2 files changed, 35 insertions, 1 deletions
diff --git a/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs b/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs index 7614796a..5e1dcd79 100644 --- a/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs +++ b/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs @@ -312,6 +312,12 @@ namespace Xamarin.Forms.ControlGallery.iOS uilabel.SetBinding("Text", new Binding("NativeLabel")); uilabel.SetBinding(nameof(uilabel.TextColor), new Binding("NativeLabelColor", converter: nativeColorConverter)); + var kvoSlider = new KVOUISlider(); + kvoSlider.MaxValue = 100; + kvoSlider.MinValue = 0; + kvoSlider.SetBinding(nameof(kvoSlider.KVOValue), new Binding("Age", BindingMode.TwoWay)); + sl?.Children.Add(kvoSlider); + var uiView = new UIView(new RectangleF(0, 0, width, heightCustomLabelView)); uiView.Add(uilabel); sl?.Children.Add(uiView); @@ -323,6 +329,34 @@ namespace Xamarin.Forms.ControlGallery.iOS } } + [Register("KVOUISlider")] + public class KVOUISlider : UISlider + { + + public KVOUISlider() + { + ValueChanged += (s, e) => KVOValue = Value; + } + + float _kVOValue; + [Export("kvovalue")] + public float KVOValue + { + get + { + + return _kVOValue; + } + set + { + + WillChangeValue(nameof(KVOValue).ToLower()); + _kVOValue = Value = value; + DidChangeValue(nameof(KVOValue).ToLower()); + } + } + } + public class ColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj b/Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj index fabf981a..aa9c7d91 100644 --- a/Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj +++ b/Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj @@ -270,4 +270,4 @@ <Visible>False</Visible> </XamarinComponentReference> </ItemGroup> -</Project>
\ No newline at end of file +</Project> |