Ejemplo n.º 1
0
        public BackgroundColorPage()
        {
            /*
             * This is a bit of a hack. Android's renderer for TableView always adds an empty header for a
             * TableSection declaration, while iOS doesn't. To compensate, I'm using a Label to display info text
             * on iOS, and the TableSection on Android since there is no easy way to get rid of it.This is a
             * long-standing bug in the XF TableView on Android.
             * (https://forums.xamarin.com/discussion/18037/tablesection-w-out-header)
             */
            TableSection section;

            if (Device.RuntimePlatform == Device.Android)
            {
                section = new TableSection("Cell BackgroundColor values set in C#:");
            }
            else
            {
                section = new TableSection();
            }

            var cell = new TextCell {
                Text = "Red", TextColor = Color.White
            };

            CellGloss.SetBackgroundColor(cell, Color.Red);
            section.Add(cell);

            cell = new TextCell {
                Text = "Green", TextColor = Color.White
            };
            CellGloss.SetBackgroundColor(cell, Color.Green);
            section.Add(cell);

            cell = new TextCell {
                Text = "Blue", TextColor = Color.White
            };
            CellGloss.SetBackgroundColor(cell, Color.Blue);
            section.Add(cell);

            var stack = new StackLayout();

            if (Device.RuntimePlatform == Device.iOS)
            {
                stack.Children.Add(new Label {
                    Text = "Cell BackgroundColor values set in C#:", Margin = new Thickness(10)
                });
            }
            stack.Children.Add(new TableView
            {
                Intent        = TableIntent.Data,
                HeightRequest = DeviceExtensions.OnPlatform <double>(132, 190, 0),
                Root          = new TableRoot
                {
                    section
                }
            });

            Content = stack;
        }
        private void PauseResumeClock(object sender, EventArgs e)
        {
            ShouldContinue = !ShouldContinue;

            if (ShouldContinue)
            {
                CellGloss.SetBackgroundColor(ElapsedTimeCell, Color.White);

                if (!IsRunning)
                {
                    IsRunning = true;

                    Device.StartTimer(TimeSpan.FromSeconds(1), this.RunTimer);
                }
            }
            else
            {
                CellGloss.SetBackgroundColor(ElapsedTimeCell, Color.LightGoldenrodYellow);
            }
        }
        TableSection buildTeamMembers()
        {
            var sect = new TableSection("Team Member");

            Members = new List <TeamMember>();

            foreach (var member in LocalRealmInstance.All <TeamMember>())
            {
                Members.Add(member);
            }

            foreach (var m in Members)
            {
                var tc = new TextCell
                {
                    Text   = m.Name,
                    Detail = m.Username
                };

                tc.Command = new Command(() =>
                {
                    if (SelectedTeamMemberCell != null)
                    {
                        CellGloss.SetBackgroundColor(SelectedTeamMemberCell, Color.White);
                    }

                    SelectedTeamMember     = m;
                    SelectedTeamMemberCell = tc;

                    CellGloss.SetBackgroundColor(tc, Color.LightGreen);
                });

                sect.Add(tc);
            }

            return(sect);
        }