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


C# ContentView.SetBinding方法代碼示例

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


在下文中一共展示了ContentView.SetBinding方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CustomerOrderListViewGroupHeaderCell

        public CustomerOrderListViewGroupHeaderCell()
        {
            var title = new Label
            {
                FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))),
                TextColor = Color.White,
                VerticalOptions = LayoutOptions.Center,
                FontAttributes = FontAttributes.Bold
            };
            title.SetBinding(Label.TextProperty, "Key");

            var contentView = new ContentView() { Content = title, HeightRequest = Sizes.MediumRowHeight, Padding = new Thickness(10, 0) };

            contentView.SetBinding(StackLayout.BackgroundColorProperty, "Key", converter: new OrderListHeaderViewBackgroudColorConverter());

            View = contentView;
        }
開發者ID:rrawla,項目名稱:app-crm,代碼行數:17,代碼來源:CustomerOrderListViewGroupHeaderCell.cs

示例2: Init


//.........這裏部分代碼省略.........
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                })
            );

            relativeLayout.Children.Add(btnBack,
                Constraint.RelativeToParent((parent) => {
                    return 0;
                }),
                Constraint.RelativeToParent((parent) => {
                    return statusBarHeight;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                })
            );

            relativeLayout.Children.Add(btnAction,
                Constraint.RelativeToParent((parent) => {
                    return parent.Width - wButton * 2;
                }),
                Constraint.RelativeToParent((parent) => {
                    return statusBarHeight;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton * 2;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                })
            );

            relativeLayout.Children.Add(btnSave,
                Constraint.RelativeToParent((parent) => {
                    return parent.Width - wButton * 2;
                }),
                Constraint.RelativeToParent((parent) => {
                    return statusBarHeight;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton * 2;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                })
            );

           
            relativeLayout.Children.Add(lblTitle,
                Constraint.RelativeToParent((parent) => {
                    return 10;
                }),
                Constraint.RelativeToParent((parent) => {
                    return pTestata;
                }),
                Constraint.RelativeToParent((parent) => {
                    return parent.Width - 20;
                }),
                Constraint.RelativeToParent((parent) => {
                    return hLblTitle;
                })
            );

            abs = new AbsoluteLayout();

            AbsoluteLayout.SetLayoutFlags(relativeLayout, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(relativeLayout, new Rectangle(0, 0, 1, 1));
            abs.Children.Add(relativeLayout);

            //****ACTIVITY INDICATOR*******//
            #region activityIndicator
            var backIndicator = new ContentView();
            backIndicator.BackgroundColor = Color.Black;
            backIndicator.IsVisible = IsLoading;
            backIndicator.Opacity = 0.5;
            backIndicator.BindingContext = this;
            backIndicator.SetBinding(ContentView.IsVisibleProperty, "IsLoading");
            AbsoluteLayout.SetLayoutFlags(backIndicator, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(backIndicator, new Rectangle(0, 0, 1, 1));
            abs.Children.Add(backIndicator);

            var actIndicator = new ActivityIndicator();
            actIndicator.IsVisible = IsLoading;
            actIndicator.IsRunning = IsLoading;
            actIndicator.BindingContext = this;
            actIndicator.BackgroundColor = Color.Transparent;
            actIndicator.Color = Color.White;
            actIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsLoading");
            actIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
            AbsoluteLayout.SetLayoutFlags(actIndicator, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(actIndicator, new Rectangle(0.5, 0.5, -1, -1));
            abs.Children.Add(actIndicator);
            #endregion

            this.Content = abs;
        }
開發者ID:lima66,項目名稱:SampleAppXamarin,代碼行數:101,代碼來源:GloboContentPage.cs

示例3: SimonSaysPage


//.........這裏部分代碼省略.........

			var buttonConstraint = Constraint.RelativeToParent((p) => (p.Width / 2) - AppSettings.Margin - AppSettings.ItemPadding / 2);

			layout.Children.Add(red,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.Constant(AppSettings.Margin),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(yellow,
				xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
				yConstraint: Constraint.Constant(AppSettings.Margin),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(blue,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToView(red, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(green,
				xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
				yConstraint: Constraint.RelativeToView(yellow, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(lightStack,
				xConstraint: Constraint.Constant(AppSettings.Margin - stackPadding),
				yConstraint: Constraint.RelativeToView(blue, (p, v) => v.Height + v.Y + AppSettings.ItemPadding * 2),
				widthConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin * 2 + stackPadding * 2),
				heightConstraint: Constraint.Constant(25) // TODO calculate the square size based on the width of the view
			);
			layout.Children.Add(clearSubmission,
				xConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin - Device.OnPlatform(10, 15, 15)),
				yConstraint: Constraint.RelativeToView(lightStack, (p, v) => Device.OnPlatform(
																				v.Y - 10,
																				v.Y - 15,
																				v.Y - 15
																			)
				),
				widthConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30)),
				heightConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30))
			);

			layout.Children.Add(actionButton,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
				heightConstraint: Constraint.Constant(50)
			);

			Content = layout;

			red.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("r");
			};
			blue.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("b");
			};
			green.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("g");
			};
			yellow.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("y");
			};
			clearSubmission.Clicked += (object sender, EventArgs e) =>
			{
				ViewModel.ClearPlayerEntry();
			};

			red.SetBinding(Button.OpacityProperty, "RedOpacity");
			green.SetBinding(Button.OpacityProperty, "GreenOpacity");
			blue.SetBinding(Button.OpacityProperty, "BlueOpacity");
			yellow.SetBinding(Button.OpacityProperty, "YellowOpacity");

			l1.SetBinding(ContentView.BackgroundColorProperty, "L1");
			l2.SetBinding(ContentView.BackgroundColorProperty, "L2");
			l3.SetBinding(ContentView.BackgroundColorProperty, "L3");
			l4.SetBinding(ContentView.BackgroundColorProperty, "L4");
			l5.SetBinding(ContentView.BackgroundColorProperty, "L5");
			l6.SetBinding(ContentView.BackgroundColorProperty, "L6");
			l7.SetBinding(ContentView.BackgroundColorProperty, "L7");
			l8.SetBinding(ContentView.BackgroundColorProperty, "L8");
			l9.SetBinding(ContentView.BackgroundColorProperty, "L9");
			l10.SetBinding(ContentView.BackgroundColorProperty, "L10");

			clearSubmission.SetBinding(Button.IsVisibleProperty, "ShowClearButton");
			actionButton.SetBinding(Button.BackgroundColorProperty, "ActionColor");
			actionButton.SetBinding(Button.TextProperty, "ActionText");
			actionButton.SetBinding(Button.CommandProperty, "ActionCommand");
		}
開發者ID:xamarin,項目名稱:mini-hacks,代碼行數:101,代碼來源:SimonSaysPage.cs


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