public MaterialTabViewItemTemplate() { _visualFeedback = new VisualFeedbackEffect(); Effects.Add(_visualFeedback); RowSpacing = 0; HorizontalOptions = LayoutOptions.FillAndExpand; VerticalOptions = LayoutOptions.FillAndExpand; RowDefinitions.Add(new RowDefinition { Height = GridLength.Star }); RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); _icon = new Image { Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 6) }; _text = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 6) }; _badge = new BadgeView { PlacementTarget = _icon, Margin = new Thickness(0) }; Children.Add(_icon); Children.Add(_text); Children.Add(_badge); SetRow(_icon, 0); SetRow(_text, 1); SetRow(_badge, 0); SetRowSpan(_badge, 2); }
protected override void OnParentSet() { base.OnParentSet(); BindingContext = Parent; _icon.SetBinding(Image.SourceProperty, "CurrentIcon"); _text.SetBinding(Label.TextProperty, "Text", BindingMode.OneWay, new ToUpperConverter()); _text.SetBinding(Label.TextColorProperty, "CurrentTextColor"); _text.SetBinding(Label.FontSizeProperty, "CurrentFontSize"); _text.SetBinding(Label.FontAttributesProperty, "CurrentFontAttributes"); _text.SetBinding(Label.FontFamilyProperty, "CurrentFontFamily"); _badge.SetBinding(BadgeView.BackgroundColorProperty, "CurrentBadgeBackgroundColor"); _badge.SetBinding(BadgeView.TextProperty, "BadgeText"); _badge.SetBinding(BadgeView.TextColorProperty, "BadgeTextColor"); VisualFeedbackEffect.SetFeedbackColor(this, Color.White); }