summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.ControlGallery.iOS
diff options
context:
space:
mode:
authorRui Marinho <me@ruimarinho.net>2016-09-30 19:48:22 +0100
committerJason Smith <jason.smith@xamarin.com>2016-09-30 11:48:22 -0700
commitfa2f01680d23a813a5b1ab7795151b6dcb0feb7f (patch)
tree74e7d0e301f237cde7a0b1ce4e95d53ebcc80a43 /Xamarin.Forms.ControlGallery.iOS
parentc07c2314f5737d480088319e87ab299b22cb4ddc (diff)
downloadxamarin-forms-fa2f01680d23a813a5b1ab7795151b6dcb0feb7f.tar.gz
xamarin-forms-fa2f01680d23a813a5b1ab7795151b6dcb0feb7f.tar.bz2
xamarin-forms-fa2f01680d23a813a5b1ab7795151b6dcb0feb7f.zip
[iOS] Keep our native property listener around the same time we keep our proxy, check if we are KVO compliant before adding observer (#403)
Diffstat (limited to 'Xamarin.Forms.ControlGallery.iOS')
-rw-r--r--Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs61
-rw-r--r--Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj4
2 files changed, 50 insertions, 15 deletions
diff --git a/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs b/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs
index 3eb36bfc..71c5e0c6 100644
--- a/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs
+++ b/Xamarin.Forms.ControlGallery.iOS/AppDelegate.cs
@@ -156,7 +156,7 @@ namespace Xamarin.Forms.ControlGallery.iOS
MessagingCenter.Subscribe<Bugzilla40911>(this, Bugzilla40911.ReadyToSetUp40911Test, SetUp40911Test);
// When the native binding gallery loads up, it'll let us know so we can set up the native bindings
- MessagingCenter.Subscribe<NativeBindingGalleryPage >(this, NativeBindingGalleryPage.ReadyForNativeBindingsMessage, AddNativeBindings);
+ MessagingCenter.Subscribe<NativeBindingGalleryPage>(this, NativeBindingGalleryPage.ReadyForNativeBindingsMessage, AddNativeBindings);
LoadApplication(app);
return base.FinishedLaunching(uiApplication, launchOptions);
@@ -297,6 +297,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);
@@ -321,32 +327,61 @@ namespace Xamarin.Forms.ControlGallery.iOS
page.Layout.Children.Add(button);
}
- public void StartPressed40911 ()
- {
+ public void StartPressed40911()
+ {
var loginViewController = new UIViewController { View = { BackgroundColor = UIColor.White } };
- var button = UIButton.FromType (UIButtonType.RoundedRect);
- button.SetTitle ("Login", UIControlState.Normal);
- button.Frame = new CGRect (20, 100, 200, 44);
- loginViewController.View.AddSubview (button);
-
- button.TouchUpInside += (sender, e) => {
- Xamarin.Forms.Application.Current.MainPage = new ContentPage {Content = new Label {Text = "40911 Success"} };
- loginViewController.DismissViewController (true, null);
+ var button = UIButton.FromType(UIButtonType.RoundedRect);
+ button.SetTitle("Login", UIControlState.Normal);
+ button.Frame = new CGRect(20, 100, 200, 44);
+ loginViewController.View.AddSubview(button);
+
+ button.TouchUpInside += (sender, e) =>
+ {
+ Xamarin.Forms.Application.Current.MainPage = new ContentPage { Content = new Label { Text = "40911 Success" } };
+ loginViewController.DismissViewController(true, null);
};
- var window= UIApplication.SharedApplication.KeyWindow;
+ var window = UIApplication.SharedApplication.KeyWindow;
var vc = window.RootViewController;
while (vc.PresentedViewController != null)
{
vc = vc.PresentedViewController;
}
- vc.PresentViewController (loginViewController, true, null);
+ vc.PresentViewController(loginViewController, true, null);
}
#endregion
}
+ [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 c1ef6f4c..9af0106a 100644
--- a/Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj
+++ b/Xamarin.Forms.ControlGallery.iOS/Xamarin.Forms.ControlGallery.iOS.csproj
@@ -24,7 +24,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchArch>i386, x86_64</MtouchArch>
- <MtouchLink>SdkOnly</MtouchLink>
+ <MtouchLink>None</MtouchLink>
<MtouchDebug>True</MtouchDebug>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchSdkVersion></MtouchSdkVersion>
@@ -268,4 +268,4 @@
</XamarinComponentReference>
</ItemGroup>
<Import Project="..\packages\Xamarin.Insights.1.12.3\build\Xamarin.iOS10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.12.3\build\Xamarin.iOS10\Xamarin.Insights.targets')" />
-</Project> \ No newline at end of file
+</Project>