.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,722 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
In below XAML and in codebehind, how can I access the LabelPhoneNumber in the Border's TelTapGestureRecognizer_Tapped?
<Border ClassId="TEL" BackgroundColor="White" Padding="0" Margin="5" HorizontalOptions="FillAndExpand">
<Border.StrokeShape>
<RoundRectangle CornerRadius="20" Stroke="LightGray" />
</Border.StrokeShape>
<Border.GestureRecognizers>
<TapGestureRecognizer Tapped="TelTapGestureRecognizer_Tapped" NumberOfTapsRequired="1" />
</Border.GestureRecognizers>
<Grid ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto">
<Frame Grid.Column="0" Grid.RowSpan="2" IsClippedToBounds="True" BackgroundColor="Green" CornerRadius="20" Margin="15" Padding="0" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="40" HeightRequest="40">
<Image Aspect="Center">
<Image.Source>
<FontImageSource FontFamily="FontSolid" Glyph="{x:Static local:IconFont.IconCall}" Color="White" Size="20" />
</Image.Source>
</Image>
</Frame>
<Label Grid.Column="1" Grid.Row="0" Text="Telephone" Margin="5,0,0,0" VerticalOptions="End" />
<Label Grid.Column="1" Grid.Row="1" Text="{Binding PhoneNumber}" Margin="5,0,0,0" VerticalOptions="Start" />
</Grid>
</Border>
Thanks,
Jassim
I found the solution:
private void TelTapGestureRecognizer_Tapped(object sender, EventArgs e)
{
var border = (Border)sender;
var grid = (Grid)border.FindByName("GridTelephones");
var label = (Label)grid.FindByName("LabelPhoneNumber");
string phoneNumber = label.Text;
}