simple question

hamzab2013hamzab2013 ✭✭Member ✭✭

is there anyway i can change my app backroundcolor using code not xaml i want change tthe backround color when i click the buttton is that possible ????

Best Answer

Answers

  • Mikael_GirouxMikael_Giroux ✭✭ USMember ✭✭
    edited January 2018

    You can use the property BackgroundColor:
    Example: XAML
    <stackLayout x:name="MyStack"> <Label Text="Hello"/> <Button x:name="MyBTN_Red" Clicked="MyBTN_Red_Clicked"/> <Button x:name="MyBTN_Blue" Clicked="MyBTN_Blue_Clicked"/> </StackLayout>

    CODE:
    private void MyBTN_Red_Clicked(object sender, EventArg e)
    {
    MyStack.BackgroundColor= Color.Red;
    }
    private void MyBTN_Blue_Clicked(object sender, EventArg e)
    {
    MyStack.BackgroundColor= Color.Blue;
    }

  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭

    @hamzab2013 said:
    is there anyway i can change my app backroundcolor using code not xaml i want change tthe backround color when i click the buttton is that possible ????

    you mean entire app or just for single activity ?

  • hamzab2013hamzab2013 ✭✭ Member ✭✭

    well im a beginner my whole app is composed of one activity (mainactivity) :p i want change the backround color when i click a button i mean like its black now and when i click i want it to be red for example

  • hamzab2013hamzab2013 ✭✭ Member ✭✭

    no one knows ?????

Sign In or Register to comment.