I have a problem. I created this frame:
<Frame BackgroundColor="Black" BorderColor="DarkGray" CornerRadius="20" HeightRequest="40" Padding="10,0,10,0">
<Label Text="{Binding Name}" FontSize="20" TextColor="White" VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"/>
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="Category_Clicked" />
</Frame.GestureRecognizers>
</Frame>
And in the code behind I have this event:
List<string> selectedCategories = new List<string>();
private void Category_Clicked(object sender, EventArgs e)
{
Frame frame = (Frame)sender;
if (frame.BackgroundColor == Color.Black)
{
frame.BackgroundColor = Color.FromHex("#2196F3");
//Add label text to list
}
else
{
frame.BackgroundColor = Color.Black;
//Remove label text from list
}
}
But I need to access the text from the label inside the Frame. How can I do that?
Name
, so just use theName
property of your VM – JasonFrame
withContent
property. Is pretty straight forward. Correct me if I'm doing it wrong (Any best practice rules I'm missing). – Nikhileshwar