Xamarin.forms jak pobrać ID z imagebutton?

0

Tak jak w temacie, chciałbym się dowiedzieć w jaki sposób pobrać id po wciśnięciu w imagebutton.
Mój kod z XAML:

<ListView Margin="0,0,0,-100" x:Name="routesList"
                HorizontalOptions="Center"  
                VerticalOptions="Center"
                ItemTapped="OnTapped"
                SelectionMode="None"
                ItemsSource="{Binding Routes}"
                SeparatorColor="#90B320"
                HasUnevenRows="True">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Vertical">
                                <StackLayout Orientation="Horizontal">
                                   <Label Text="Nr." TextColor="Black"
                                           FontAttributes="Bold" FontSize="15"
                                           HorizontalTextAlignment="Center"
                                           Margin="5,10,20,10"/>
                                   <Label Text="{Binding Id}" TextColor="Black"
                                           FontAttributes="Bold" FontSize="15"
                                           HorizontalTextAlignment="Center"
                                           Margin="-25,10,0,0"/>
                                   <Label Text="{Binding Name}"
                                   TextColor="Black"
                                   HorizontalTextAlignment="Center"
                                   FontAttributes="Bold" 
                                   FontSize="15"
                                   Margin="20,10,20,10"/>
                                   <Label Text="{Binding Description}"
                                   TextColor="Black"
                                   HorizontalTextAlignment="Center"
                                   VerticalTextAlignment="Center"
                                   FontAttributes="Italic" 
                                   FontSize="10"
                                   Margin="10"/>
                                    <ImageButton x:Name="quizButton" Source="quiz2.png"
                                            HorizontalOptions="EndAndExpand" VerticalOptions="CenterAndExpand"
                                            Clicked="OnQuizClicked" BackgroundColor="#FDDA8A" CornerRadius="20"
                                            WidthRequest="70" HeightRequest="70" Margin="3"/>
                                </StackLayout>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

w C# coś kombinowałem:

    private async void OnQuizClicked(object sender, EventArgs e)
        {
             var button = sender as Button;
             var route = button?.BindingContext as Routes;
            
            var token = Application.Current.Properties["MyToken"].ToString();
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            var response = await client.GetStringAsync("URL");
            List<Question> punkty = JsonConvert.DeserializeObject<List<Question>>(response);
            List<Question> list = new List<Question>();
            foreach (Question tmp in punkty)
            {
                if (tmp.RouteId == route.Id)
                {
                    list.Add(tmp);
                }
            }


            await Navigation.PushAsync(new UserQuestionPage());
        }
0

Juz sobie poradzilem, moje niedopatrzenie: edytowałem "Button" na "ImageButton"

1 użytkowników online, w tym zalogowanych: 0, gości: 1