當前位置: 首頁>>代碼示例>>C#>>正文


C# Forms.VisualElement類代碼示例

本文整理匯總了C#中Xamarin.Forms.VisualElement的典型用法代碼示例。如果您正苦於以下問題:C# VisualElement類的具體用法?C# VisualElement怎麽用?C# VisualElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VisualElement類屬於Xamarin.Forms命名空間,在下文中一共展示了VisualElement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnModelChanged

        protected override void OnModelChanged(VisualElement oldModel, VisualElement newModel)
        {
            base.OnModelChanged(oldModel, newModel);

            // this is a ViewGroup - so should be able to load an AXML file and FindView<>
            var activity = this.Context as Activity;

            var auth = new OAuth2Authenticator(
                clientId: "574134802616730", // your OAuth2 client id
                scope: "email,user_about_me", // the scopes for the particular API you're accessing, delimited by "+" symbols
                authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"), // the auth URL for the service
                redirectUrl: new Uri("https://www.cautom.com/SocialAuth/FBLogin/")); // the redirect URL for the service

            auth.Completed += (sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    //App.SuccessfulLoginAction.Invoke();
                    // Use eventArgs.Account to do wonderful things
                    //App.SaveToken(eventArgs.Account.Properties["access_token"]);
                    string accessToken = eventArgs.Account.Properties["access_token"];
                    new FacebookLoginWebView().fetchUserInfoFromAccessToken(accessToken);
                }
                else
                {
                    // The user cancelled
                }
            };

            activity.StartActivity(auth.GetUI(activity));
        }
開發者ID:getsaurabh02,項目名稱:M2EMobile,代碼行數:31,代碼來源:LoginPageRenderer.cs

示例2: OnElementChanged

        protected override void OnElementChanged(VisualElement oldElement, VisualElement newElement)
        {
            base.OnElementChanged(oldElement, newElement);

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= this.HandleMasterDetailPagePropertyChanged;
                oldElement.PropertyChanging -= this.HandleMasterDetailPagePropertyChanging;
            }

            if (newElement != null)
            {
                newElement.PropertyChanged += this.HandleMasterDetailPagePropertyChanged;
                newElement.PropertyChanging += this.HandleMasterDetailPagePropertyChanging;
            }

            if (oldElement == null && newElement != null)
            {
                this.SetFitsSystemWindows(true);

                var activity = (Activity)this.Context;

                this.actionBarDrawerToggle = new CustomActionBarDrawerToggle(this, activity, this) { DrawerIndicatorEnabled = true };

                this.ActionBar.SetDisplayHomeAsUpEnabled(true);
                this.ActionBar.SetHomeButtonEnabled(true);

                this.actionBarDrawerToggle.SyncState();

                this.BindNavigationEventHandlers();
            }
        }
開發者ID:jdluzen,項目名稱:oss-xamarin,代碼行數:32,代碼來源:AppCompatMasterDetailRenderer.cs

示例3: OnModelChanged

		protected override void OnModelChanged (VisualElement oldModel, VisualElement newModel)
		{
			base.OnModelChanged (oldModel, newModel);

			// this is a ViewGroup - so should be able to load an AXML file and FindView<>
			var activity = this.Context as Activity;

			var auth = new OAuth2Authenticator (
				clientId: App.Instance.OAuthSettings.ClientId, // your OAuth2 client id
				scope: App.Instance.OAuthSettings.Scope, // The scopes for the particular API you're accessing. The format for this will vary by API.
				authorizeUrl: new Uri (App.Instance.OAuthSettings.AuthorizeUrl), // the auth URL for the service
				redirectUrl: new Uri (App.Instance.OAuthSettings.RedirectUrl)); // the redirect URL for the service

			auth.Completed += (sender, eventArgs) => {
				if (eventArgs.IsAuthenticated) {
					App.Instance.SuccessfulLoginAction.Invoke();
					// Use eventArgs.Account to do wonderful things
					App.Instance.SaveToken(eventArgs.Account.Properties["access_token"]);
				} else {
					// The user cancelled
				}
			};

			activity.StartActivity (auth.GetUI(activity));
		}
開發者ID:Gunner92,項目名稱:OAuthTwoDemo.XForms,代碼行數:25,代碼來源:LoginPageRenderer.cs

示例4: SetElement

        public void SetElement(VisualElement element)
        {
            var oldElement = this.Element;

            if (oldElement != null)
                oldElement.PropertyChanged -= HandlePropertyChanged;

            this.Element = element;
            if (this.Element != null)
            {

                this.Element.PropertyChanged += HandlePropertyChanged;
            }

            ViewGroup.RemoveAllViews();
            Tracker = new VisualElementTracker(this);

            Packager = new VisualElementPackager(this);
            Packager.Load();

            UseCompatPadding = true;

            SetContentPadding((int)TheView.Padding.Left, (int)TheView.Padding.Top,
                   (int)TheView.Padding.Right, (int)TheView.Padding.Bottom);

            Radius = TheView.CornerRadius;
            SetCardBackgroundColor(TheView.BackgroundColor.ToAndroid());

            if (ElementChanged != null)
                ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element));
        }
開發者ID:cesartomatis,項目名稱:Xamarin-Forms-CardView,代碼行數:31,代碼來源:AndroidCustomCardRenderer.cs

示例5: SetElement

        /// <summary>
        /// Setup our SwipeRefreshLayout and register for property changed notifications.
        /// </summary>
        /// <param name="element">Element.</param>
        public void SetElement(VisualElement element)
        {
            var oldElement = Element;

            //unregister old and re-register new
            if (oldElement != null)
                oldElement.PropertyChanged -= HandlePropertyChanged;

            Element = element;
            if (Element != null)
            {
                UpdateContent();
                Element.PropertyChanged += HandlePropertyChanged;
            }

            if (!init)
            {
                init = true;
                //sizes to match the forms view
                //updates properties, handles visual element properties
                Tracker = new VisualElementTracker(this);
                SetOnRefreshListener(this);
            }

            UpdateColors();
            UpdateIsRefreshing();
            UpdateIsSwipeToRefreshEnabled();

            if (ElementChanged != null)
                ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element));
        }
開發者ID:cleardemon,項目名稱:Xamarin.Forms-PullToRefreshLayout,代碼行數:35,代碼來源:PullToRefreshLayoutRenderer.cs

示例6: Invoke

 async protected override void Invoke(VisualElement visual)
 {
     visual.AnchorX = Anchor.X;
     visual.AnchorY = Anchor.Y;
     await Task.Delay(Delay);
     await visual.ScaleTo(Scale, (uint)Length, Easing);
 }
開發者ID:jenart,項目名稱:xamarin-forms-book-preview-2,代碼行數:7,代碼來源:DelayedScaleAction.cs

示例7: SetElement

        public void SetElement(VisualElement element)
        {
            var oldElement = this.Element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= this.HandlePropertyChanged;
            }

            this.Element = element;

            if (this.Element != null)
            {
                this.Element.PropertyChanged += this.HandlePropertyChanged;
            }

            this.RemoveAllSubviews();
            this.Tracker = new VisualElementTracker(this);

            this.Packager = new VisualElementPackager(this);
            this.Packager.Load();

            this.SetContentPadding((int)TheView.Padding.Left, (int)TheView.Padding.Top, (int)TheView.Padding.Right, (int)TheView.Padding.Bottom);

            this.SetCardBackgroundColor(this.TheView.BackgroundColor.ToUIColor());

            if (ElementChanged != null)
            {
                this.ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element));
            }
        }
開發者ID:cesartomatis,項目名稱:Xamarin-Forms-CardView,代碼行數:31,代碼來源:AppleCustomCardRenderer.cs

示例8: SetElement

        public void SetElement(VisualElement element)
        {
            var oldElement = this.Element;

            if (oldElement != null)
            {
                this.HookPropertyChanged(oldElement);
            }

            if (oldElement == null)
            {
                this.Element = element;
                this.UnhookPropertyChanged(this.Element);
                this.Tracker = new VisualElementTracker(this);

                if (this.Control == null)
                {
                    this.Control = this.CreateFloatingActionButton();
                    this.Control.Clickable = true;
                    this.Control.SetOnClickListener(new OnClickListener(x => this.FloatingButton.ExecuteCommand()));

                    this.UpdateColorState();
                    this.UpdateIcon();
                }

                this.AddView(this.Control);
            }

            this.OnElementChanged(new VisualElementChangedEventArgs(oldElement, this.Element));
        }
開發者ID:jdluzen,項目名稱:oss-xamarin,代碼行數:30,代碼來源:FloatingButtonRenderer.cs

示例9: SetElement

        public void SetElement(VisualElement element)
        {
            var oldElement = this.Element;

            if (oldElement != null)
                oldElement.PropertyChanged -= HandlePropertyChanged;

            this.Element = element;
            if (this.Element != null) {
                //UpdateContent ();
                this.Element.PropertyChanged += HandlePropertyChanged;
            }

            this.ViewGroup.RemoveAllViews ();
            //sizes to match the forms view
            //updates properties, handles visual element properties
            this.Tracker = new VisualElementTracker (this);

            this.Packager = new VisualElementPackager (this);
            this.Packager.Load ();

            this.UseCompatPadding = true;

            this.SetContentPadding ((int)TheView.Padding.Left, (int)TheView.Padding.Top, (int)TheView.Padding.Right, (int)TheView.Padding.Bottom);

            this.Radius = TheView.CornderRadius;

            this.SetCardBackgroundColor(TheView.BackgroundColor.ToAndroid ());
            if (this.ElementChanged != null)
            {
                this.ElementChanged(this, new VisualElementChangedEventArgs(oldElement, this.Element));
            }
        }
開發者ID:harrysaggu,項目名稱:xamarin-plugins,代碼行數:33,代碼來源:CardViewRenderer.cs

示例10: LayoutOperation

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="element">The element that caused the layout operation.</param>
 /// <param name="other">The list of other elements that were affected by the operation.</param>
 /// <param name="direction">The direction that the layout should be performed in.</param>
 /// <param name="value">The value that the elements will be affected by in the layout direction.</param>
 internal LayoutOperation(VisualElement element, IEnumerable<VisualElement> other, LayoutDirection direction, double value)
 {
     RootElement = element;
     Elements = new [] { element }.Union(other).ToList();
     Direction = direction;
     Value = value;
 }
開發者ID:cosullivan,項目名稱:Xamarin.FormsEx,代碼行數:14,代碼來源:LayoutOperation.cs

示例11: AdaptForBinding

 public static void AdaptForBinding(VisualElement element, IMvxBindingContextOwner contextOwner)
 {
     var mvxPage = element as IMvxContentPage;
     if (mvxPage != null) {
         contextOwner.BindingContext = new MvxBindingContext();
         contextOwner.BindingContext.DataContext = mvxPage.ViewModel;
     }
 }
開發者ID:martijn00,項目名稱:MvvmCross-Forms,代碼行數:8,代碼來源:MvxPresenterHelpers.cs

示例12: OnElementChanged

        protected override void OnElementChanged(VisualElement oldElement, VisualElement newElement) {
            base.OnElementChanged(oldElement, newElement);

            var fld = typeof(MasterDetailPageRenderer).GetField("detailLayout", BindingFlags.NonPublic | BindingFlags.Instance);
            var fldValue = fld.GetValue(this);
            var p = fld.FieldType.GetProperty("TopPadding", BindingFlags.Public | BindingFlags.Instance);
            p.SetValue(fldValue, 0);
        }
開發者ID:gruan01,項目名稱:Xamarin.Form.UWPTest,代碼行數:8,代碼來源:MasterDetailPageRender.cs

示例13: OnModelChanged

		protected override void OnModelChanged (VisualElement oldModel, VisualElement newModel)
		{
			base.OnModelChanged (oldModel, newModel);

			var tableView = Control as global::Android.Widget.ListView;
			tableView.DividerHeight = 0;
			tableView.SetBackgroundColor (new global::Android.Graphics.Color(0x2C, 0x3E, 0x50));
		}
開發者ID:JeffHarms,項目名稱:xamarin-forms-samples-1,代碼行數:8,代碼來源:MenuTableViewRenderer.cs

示例14: FocusEventArgs

		public FocusEventArgs(VisualElement visualElement, bool isFocused)
		{
			if (visualElement == null)
				throw new ArgumentNullException("visualElement");

			VisualElement = visualElement;
			IsFocused = isFocused;
		}
開發者ID:Costo,項目名稱:Xamarin.Forms,代碼行數:8,代碼來源:FocusEventArgs.cs

示例15: ColorAnimation

		static Task<bool> ColorAnimation(VisualElement element, string name, Func<double, Color> transform, Action<Color> callback, uint length, Easing easing)
		{
			easing = easing ?? Easing.Linear;
			var taskCompletionSource = new TaskCompletionSource<bool>();

			element.Animate<Color>(name, transform, callback, 16, length, easing, (v, c) => taskCompletionSource.SetResult(c));
			return taskCompletionSource.Task;
		}
開發者ID:RickySan65,項目名稱:xamarin-forms-samples,代碼行數:8,代碼來源:ViewExtensions.cs


注:本文中的Xamarin.Forms.VisualElement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。