I am attempting to create a form where a user can press one of four label/frame objects labeled 1, 2, 3, or 4. Upon clicking I need the frame and label to change from gray to blue. When it is unselected, I need it to change back to the gray color. I also only want to allow the users to press one button at a time. Thus when someone presses 1 and then presses 2, 1 should be unselected automatically.
I have created Gester recognizers for both the label and the frame at the same time, but I'm unsure how to get both the label and the frame to change colors simultaneously. Additionally, I have read that one way to do accomplish this is to set the "focused" element to the border color I want to change to. Does anyone have any guidance on this?
Here's the code I've started thus far - I'm unsure how to fill in each button tapped event or how to fix the frame_focused function to change the border color of the frame :
ConsumerQuote.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="One.consumerQuote">
<ContentPage.Content>
<StackLayout Orientation="Horizontal">
<StackLayout>
<Frame x:Name="frame_1" CornerRadius="15" BorderColor="Gray" WidthRequest="30" HeightRequest="30" Focused="Frame_Focused" >
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="button_1_tapped"/>
</Frame.GestureRecognizers>
<Label Text="1" TextColor="Gray" FontSize="18" HorizontalTextAlignment="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="button_1_tapped"/>
</Label.GestureRecognizers>
</Label>
</Frame>
</StackLayout>
<StackLayout>
<Frame CornerRadius="15" BorderColor="Gray" WidthRequest="30" HeightRequest="30" Focused="Frame_Focused">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="button_2_tapped"/>
</Frame.GestureRecognizers>
<Label Text="2" TextColor="Gray" FontSize="18" HorizontalTextAlignment="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="button_2_tapped"/>
</Label.GestureRecognizers>
</Label>
</Frame>
</StackLayout>
<StackLayout>
<Frame CornerRadius="15" BorderColor="Gray" WidthRequest="30" HeightRequest="30" Focused="Frame_Focused">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="button_3_tapped"/>
</Frame.GestureRecognizers>
<Label Text="3" TextColor="Gray" FontSize="18" HorizontalTextAlignment="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="button_3_tapped"/>
</Label.GestureRecognizers>
</Label>
</Frame>
</StackLayout>
<StackLayout>
<Frame CornerRadius="15" BorderColor="Gray" WidthRequest="30" HeightRequest="30" Focused="Frame_Focused">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="button_4_tapped"/>
</Frame.GestureRecognizers>
<Label Text="4" TextColor="Gray" FontSize="18" HorizontalTextAlignment="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="button_4_tapped"/>
</Label.GestureRecognizers>
</Label>
</Frame>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
ConsumerQuote.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace One
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class consumerQuoteReceived : ContentPage
{
public consumerQuoteReceived()
{
InitializeComponent();
}
private void button_1_tapped(object sender, EventArgs e)
{
frame_Focused()
}
private void button_2_tapped(object sender, EventArgs e)
{
}
private void button_3_tapped(object sender, EventArgs e)
{
}
private void button_4_tapped(object sender, EventArgs e)
{
}
private void frame_Focused(object sender, FocusEventArgs e)
{
Frame.BorderColor = Color.Blue;
}
}
}

