public MainPage() { InitializeComponent(); MyLabel.BindingContext = ToggleSwitch; // source MyLabel.SetBinding(Label.IsVisibleProperty, "IsToggled", BindingMode.TwoWay); }
public MainPage() { InitializeComponent(); MyLabel.BindingContext = dataModel; MyLabel.SetBinding(Label.TextProperty, "NumberAsString", BindingMode.OneWay); }
private void InitializeViews() { this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); { LBnumber = new MyLabel("Number"); LBnumber.SetBinding(MyLabel.TextProperty, new Binding("Number")); LBnumber.LineBreakMode = LineBreakMode.NoWrap; this.Children.Add(LBnumber, 0, 0); } { LBtime = new MyLabel("Time"); LBtime.SetBinding(MyLabel.TextProperty, new Binding("Time")); LBtime.LineBreakMode = LineBreakMode.NoWrap; this.Children.Add(LBtime, 1, 0); } { LBlog = new MyLabel("Log"); LBlog.SetBinding(MyLabel.TextProperty, new Binding("Log")); LBlog.SetBinding(MyLabel.FontAttributesProperty, new Binding("FontAttributes")); LBlog.LineBreakMode = LineBreakMode.NoWrap; //LBlog.SetBinding(MyLabel.LineBreakModeProperty, new Binding("LineBreakMode")); this.Children.Add(LBlog, 2, 0); } var gestureRecognizer = new TapGestureRecognizer(); gestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, "Tapped"); this.GestureRecognizers.Add(gestureRecognizer); //StackLayout sl = new StackLayout { Orientation = StackOrientation.Horizontal }; //sl.Children.Add(new Label { Text = $"#{++cnt}\t", LineBreakMode = LineBreakMode.NoWrap }); //sl.Children.Add(new Label { Text = $"{DateTime.Now}\t", LineBreakMode = LineBreakMode.NoWrap }); //sl.Children.Add(new Label { Text = text, LineBreakMode = LineBreakMode.NoWrap }); }
public View GetView(bool WithBinding) { if (WithBinding) { this.SetBinding(CustomFreeProductStuffListCell.StuffIdProperty, "StuffId"); } Grid GridWrapper = new Grid() { Padding = new Thickness(5, 0), RowSpacing = 1, ColumnSpacing = 1, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex(WithBinding ? "#DCE6FA" : "#0062C4") }; GridWrapper.RowDefinitions.Add(new RowDefinition() { Height = WithBinding ? 45 : 25 }); GridWrapper.RowDefinitions.Add(new RowDefinition() { Height = WithBinding ? 45 : 25 }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(3, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(3, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0.5, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) }); Label CodeLabel = null, NameLabel = null, UnitNameLabel = null, StockLabel = null, FeeLabel = null, PriceLabel = null, QuantityLabel = null, AddedQuantityPlusLabel = null, AddedQuantityMinusLabel = null; Label AddedQuantityEntry = null; CodeLabel = new Label() { LineBreakMode = LineBreakMode.HeadTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; NameLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; UnitNameLabel = WithBinding ? new FullRoundedLabel() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = 16, Margin = 0 } : new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; StockLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; FeeLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "1845A5" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; PriceLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "1845A5" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; QuantityLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; AddedQuantityPlusLabel = new RightEntryCompanionLabel() { LineBreakMode = LineBreakMode.TailTruncation, Text = "+", TextColor = Color.FromHex("222"), HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = 16, Margin = 1 }; AddedQuantityMinusLabel = new LeftEntryCompanionLabel() { LineBreakMode = LineBreakMode.TailTruncation, Text = "-", TextColor = Color.FromHex("222"), HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = 16, Margin = 1 }; AddedQuantityEntry = new MyLabel() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex("222"), HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = 16, Margin = 0, BackgroundColor = Color.FromHex("fff"), Padding = new Thickness(10) }; GridWrapper.Children.Add(CodeLabel, 7, 0); GridWrapper.Children.Add(NameLabel, 1, 0); Grid.SetColumnSpan(NameLabel, 6); GridWrapper.Children.Add(UnitNameLabel, 0, 0); if (WithBinding) { GridWrapper.Children.Add(PriceLabel, 0, 1); GridWrapper.Children.Add(FeeLabel, 1, 1); GridWrapper.Children.Add(AddedQuantityMinusLabel, 3, 1); GridWrapper.Children.Add(AddedQuantityEntry, 4, 1); GridWrapper.Children.Add(AddedQuantityPlusLabel, 5, 1); GridWrapper.Children.Add(QuantityLabel, 6, 1); GridWrapper.Children.Add(StockLabel, 7, 1); } else { GridWrapper.Children.Add(PriceLabel, 0, 1); GridWrapper.Children.Add(FeeLabel, 1, 1); GridWrapper.Children.Add(QuantityLabel, 3, 1); Grid.SetColumnSpan(QuantityLabel, 4); GridWrapper.Children.Add(StockLabel, 7, 1); } if (WithBinding) { CodeLabel.SetBinding(Label.TextProperty, "StuffCode"); NameLabel.SetBinding(Label.TextProperty, "StuffName"); UnitNameLabel.SetBinding(Label.TextProperty, "UnitName"); StockLabel.SetBinding(Label.TextProperty, "Stock"); FeeLabel.SetBinding(Label.TextProperty, "Fee"); PriceLabel.SetBinding(Label.TextProperty, "Price"); QuantityLabel.SetBinding(Label.TextProperty, "CurrentQuantity"); AddedQuantityEntry.SetBinding(Label.TextProperty, "AddedQuantityLabel"); } else { CodeLabel.Text = "کد کالا"; NameLabel.Text = "نام کالا"; UnitNameLabel.Text = "واحد"; StockLabel.Text = "موجودی"; FeeLabel.Text = "فی"; PriceLabel.Text = "ارزش اشانتیون"; QuantityLabel.Text = "تعداد"; } var UnitNameTapGestureRecognizer = new TapGestureRecognizer(); UnitNameTapGestureRecognizer.Tapped += UnitNameTapEventHandler; UnitNameTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "StuffId"); UnitNameLabel.GestureRecognizers.Add(UnitNameTapGestureRecognizer); var QuantityPlusTapGestureRecognizer = new TapGestureRecognizer(); QuantityPlusTapGestureRecognizer.Tapped += QuantityPlusTapEventHandler; QuantityPlusTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "StuffId"); AddedQuantityPlusLabel.GestureRecognizers.Add(QuantityPlusTapGestureRecognizer); var QuantityMinusTapGestureRecognizer = new TapGestureRecognizer(); QuantityMinusTapGestureRecognizer.Tapped += QuantityMinusTapEventHandler; QuantityMinusTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "StuffId"); AddedQuantityMinusLabel.GestureRecognizers.Add(QuantityMinusTapGestureRecognizer); var AddedQuantityTextBoxTapGestureRecognizer = new TapGestureRecognizer(); AddedQuantityTextBoxTapGestureRecognizer.Tapped += AddedQuantityTextBoxTapEventHandler; AddedQuantityTextBoxTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "StuffId"); AddedQuantityEntry.GestureRecognizers.Add(AddedQuantityTextBoxTapGestureRecognizer); return(GridWrapper); }
public View GetView(bool WithBinding) { if (WithBinding) { this.SetBinding(CustomArticleListCell.ArticleIdProperty, "Id"); } Grid GridWrapper = new Grid() { Padding = new Thickness(5, 0), RowSpacing = 1, ColumnSpacing = 1, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex(WithBinding ? "#DCE6FA" : "#0062C4") }; GridWrapper.RowDefinitions.Add(new RowDefinition() { Height = 25 }); GridWrapper.RowDefinitions.Add(new RowDefinition() { Height = WithBinding ? 45 : 25 }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(4, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(4, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0.5, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) }); GridWrapper.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(4, GridUnitType.Star) }); Label CodeLabel = null, NameLabel = null, QuantityLabel = null, PriceLabel = null, CurrentDiscountPercentLabel = null, DiscountAmountLabel = null, AfterDiscountReductionLabel = null, AddedDiscountPercentPlusLabel = null, AddedDiscountPercentMinusLabel = null; Label AddedDiscountPercentEntry = null; CodeLabel = new Label() { LineBreakMode = LineBreakMode.HeadTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; NameLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; QuantityLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; PriceLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.Start, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; CurrentDiscountPercentLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.Start, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; AddedDiscountPercentEntry = new MyLabel() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex("222"), HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = 16, Margin = 0, BackgroundColor = Color.FromHex("fff"), Padding = new Thickness(10) }; AddedDiscountPercentPlusLabel = new RightEntryCompanionLabel() { Text = "+", TextColor = Color.FromHex("222"), HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; AddedDiscountPercentMinusLabel = new LeftEntryCompanionLabel() { Text = "-", TextColor = Color.FromHex("222"), HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; DiscountAmountLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.Start, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; AfterDiscountReductionLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, TextColor = Color.FromHex(WithBinding ? "222" : "fff"), HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.Start, VerticalOptions = LayoutOptions.Center, FontSize = 16 }; GridWrapper.Children.Add(CodeLabel, 7, 0); GridWrapper.Children.Add(NameLabel, 1, 0); Grid.SetColumnSpan(NameLabel, 6); GridWrapper.Children.Add(QuantityLabel, 0, 0); GridWrapper.Children.Add(AfterDiscountReductionLabel, 0, 1); if (WithBinding) { GridWrapper.Children.Add(DiscountAmountLabel, 1, 1); GridWrapper.Children.Add(AddedDiscountPercentMinusLabel, 3, 1); GridWrapper.Children.Add(AddedDiscountPercentEntry, 4, 1); GridWrapper.Children.Add(AddedDiscountPercentPlusLabel, 5, 1); GridWrapper.Children.Add(CurrentDiscountPercentLabel, 6, 1); } else { GridWrapper.Children.Add(DiscountAmountLabel, 1, 1); GridWrapper.Children.Add(CurrentDiscountPercentLabel, 3, 1); Grid.SetColumnSpan(CurrentDiscountPercentLabel, 4); } GridWrapper.Children.Add(PriceLabel, 7, 1); if (WithBinding) { CodeLabel.SetBinding(Label.TextProperty, "StuffCode"); NameLabel.SetBinding(Label.TextProperty, "StuffName"); QuantityLabel.SetBinding(Label.TextProperty, "Quantity"); PriceLabel.SetBinding(Label.TextProperty, "SalePrice"); CurrentDiscountPercentLabel.SetBinding(Label.TextProperty, "CurrentDiscountPercent"); AddedDiscountPercentEntry.SetBinding(Label.TextProperty, "AddedDiscountPercentLabel"); DiscountAmountLabel.SetBinding(Label.TextProperty, "DiscountAmount"); AfterDiscountReductionLabel.SetBinding(Label.TextProperty, "AfterDiscountReduction"); } else { CodeLabel.Text = "کد کالا"; NameLabel.Text = "نام کالا"; QuantityLabel.Text = "تعداد"; PriceLabel.Text = "مبلغ ناخالص"; CurrentDiscountPercentLabel.Text = "تخفیف(%)"; DiscountAmountLabel.Text = "تخفیف($)"; AfterDiscountReductionLabel.Text = "با کسر تخفیف"; } var AddedDiscountPercentPlusTapGestureRecognizer = new TapGestureRecognizer(); AddedDiscountPercentPlusTapGestureRecognizer.Tapped += AddedDiscountPercentPlusTapEventHandler; AddedDiscountPercentPlusTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "Id"); AddedDiscountPercentPlusLabel.GestureRecognizers.Add(AddedDiscountPercentPlusTapGestureRecognizer); var AddedDiscountPercentMinusTapGestureRecognizer = new TapGestureRecognizer(); AddedDiscountPercentMinusTapGestureRecognizer.Tapped += AddedDiscountPercentMinusTapEventHandler; AddedDiscountPercentMinusTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "Id"); AddedDiscountPercentMinusLabel.GestureRecognizers.Add(AddedDiscountPercentMinusTapGestureRecognizer); var AddedDiscountPercentTextBoxTapGestureRecognizer = new TapGestureRecognizer(); AddedDiscountPercentTextBoxTapGestureRecognizer.Tapped += AddedDiscountPercentTextBoxTapEventHandler; AddedDiscountPercentTextBoxTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "Id"); AddedDiscountPercentEntry.GestureRecognizers.Add(AddedDiscountPercentTextBoxTapGestureRecognizer); return(GridWrapper); }