F
F
Frendy2020-02-21 22:52:49
C++ / C#
Frendy, 2020-02-21 22:52:49

How to open pages when clicking on ListView items?

I need to make it so that when the user clicks on the ListView items, the corresponding page opens. But by no means is there a method using Clicked and its own method for each element of the list. For example, when you click on the first section, you need to open Page1, when you click on the second section - Page2, and so on. How to implement this without duplicating unnecessary code?

5e5035b4cd7ad437166158.png

<ListView x:Name="listView1" SelectionMode="None" ItemTapped="OnListViewItemTapped">
            <ListView.ItemsSource>
                <x:Array Type="{x:Type x:String}">
                    <x:String>first section</x:String>
                    <x:String>Second section</x:String>
                    <x:String>Third section</x:String>
                    <x:String>fourth sectio</x:String>
                    <x:String>fifth</x:String>
                    <x:String>sixth</x:String>
                    <x:String>seventh</x:String>
                    <x:String>eighth</x:String>
                    <x:String>девятый</x:String>
                    <x:String>десятый</x:String>
                </x:Array>
            </ListView.ItemsSource>
        </ListView>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-02-21
@Frendy

hang a handler on the sheet, and datasource, bring it in the handler.
there is an example in the default app

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question