Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

RelativeLayout.Children.Add in ColumnDefinitions is not working??

$
0
0

Hi Xamarin forms developers
I create a Gird using columnDefinitions (4 column) , and Add four Imagebutton, the problem is I try to plus Badage on Imagebuttons using relativelayout, it not working. Attach is effect I want. thanks reading.
ps: Badge is come from https://alexdunn.org/2017/03/15/xamarin-controls-badgeview/

public class GridBottomPanel : Grid
    {
        private PageTypeEnum _PageType { get; set; }
        public bool IsRoot { get; set; }
        private ImageButton btnWork = new ImageButton { Source = "messageBottomIcon_01_Work", Style=(Style)Application.Current.Resources["bottomImageButtonStyle"] };
        private ImageButton btnSchedule = new ImageButton { Source = "messageBottomIcon_02_Schedule", Style = (Style)Application.Current.Resources["bottomImageButtonStyle"] };
        private ImageButton btnTrack = new ImageButton { Source = "messageBottomIcon_03_Track", Style = (Style)Application.Current.Resources["bottomImageButtonStyle"] };
        private ImageButton btnNotifi = new ImageButton { Source = "messageBottomIcon_04_Notifi", Style = (Style)Application.Current.Resources["bottomImageButtonStyle"] };
        private BadgeView WorkBadge = new BadgeView { Text = "1", BadgeColor = Color.Red , IsVisible =true};
        private BadgeView ScheduleBadge = new BadgeView { Text = "2", BadgeColor = Color.Red, IsVisible = true };
        private BadgeView TrackBadge = new BadgeView { Text = "3", BadgeColor = Color.Red, IsVisible = true };
        private BadgeView NotifiBadge = new BadgeView { Text = "4", BadgeColor = Color.Red, IsVisible = true };      

        public GridBottomPanel()
        {
            RelativeLayout relativeLayout = new RelativeLayout();
            IsRoot = false;
            ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition(),
                    new ColumnDefinition(),
                    new ColumnDefinition(),
                    new ColumnDefinition()
                };
            HorizontalOptions = LayoutOptions.Fill;
            VerticalOptions = LayoutOptions.Fill;
#region this is show imagebutton correctly
            Children.Add(btnWork, 0, 0);
            Children.Add(btnSchedule, 1, 0);
            Children.Add(btnTrack, 2, 0);
            Children.Add(btnNotifi, 3, 0);
#endregion
#region this is I try to put badge on imagebutton
            relativeLayout.Children.Add(WorkBadge,
            Constraint.RelativeToView(btnWork, (Parent, view) => {
                 return view.X + 20;
            }),
            Constraint.RelativeToView(btnWork, (parent, view) => {
                return view.Y + 10;
            }),
            Constraint.Constant(125),
            Constraint.Constant(80));
#endregion
            btnWork.Clicked += BtnWork_Clicked;
            btnSchedule.Clicked += BtnSchedule_Clicked;
            btnTrack.Clicked += BtnTrack_Clicked;
            btnNotifi.Clicked += BtnNotifi_Clicked;
        }
}

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>