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

SwitchCell.On Not Working on Android! Bug??

$
0
0

Hi,

I'm using a tableView with serveral SwitchCells inside and I need to be able to switch the state of each Switch Cell. In iOS my code works but on Android nothing changes and I dont know why. :/ Is this a known Xamarin.Forms bug?

TableView table;

public TestPage()
{

        StackLayout st = new StackLayout();
        st.HorizontalOptions = LayoutOptions.FillAndExpand;
        st.VerticalOptions = LayoutOptions.FillAndExpand;

        table = new TableView
        {
            Intent = TableIntent.Form,
            Root = new TableRoot("") {
                new TableSection
                {
                    new SwitchCell
                    {
                        Text = "SwitchCell:"
                    }
                }
            }
        };

        st.Children.Add(table);

        Button next = new Button
        {
            Text = "Ok",
        };
        next.Clicked +=next_Clicked;

        st.Children.Add(next);

        Content = st;
    } 

    void next_Clicked(object sender, EventArgs e)
    {
        ((SwitchCell)table.Root[0].ElementAt(0)).On = !((SwitchCell)table.Root[0].ElementAt(0)).On;
    }

PS: BTW is normal to have two switches in Android?


Viewing all articles
Browse latest Browse all 58056

Trending Articles