Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Change background color of two buttons using triggers

I am working with xamarin forms in UWP based application and I want to change the background color of two buttons which are side by side each other, i.e. when I select Button A my Button B should change its color to Red and Button A should change its color to Green and When I select Button B, Button A should change its color to Red and Button B should change its background color to Green.

So far i have used triggers and am able to work with one button at one time, but my requirement is a bit different here I would like to work with both the buttons using triggers.

Please let me know whats the possible solution for this

Best Answer


  • 15mgm1515mgm15 USMember ✭✭✭✭

    Is it a must to use triggers? can't you do it by hand? it may be faster to catch the clicked events and change the background color's on those events.

  • RaviDixitRaviDixit USMember ✭✭

    @15mgm15 its not compulsory to use triggers, the project that i have is in MVVM style and I have a separate view model class for my view class.

    I am not writing the entire code in the xaml.cs file its been divided in the view model class file and hence I thought trigger is the only solution as I am doing a conditional check and then changing the colors

    Any idea on how can i do this in an MVVM style or whats the best bet here

Sign In or Register to comment.