András Tóth‘s professional blog
banditoth.net

Hey there 👋, I’m banditoth a .NET MAUI developer from Hungary.
I write about software development with .NET technologies.

You can find me on:
LinkedIn | Github | StackOverflow | X / Twitter | Threads

Xamarin iOS: Entry Unfocus event nem triggerelődik, ListView-el.

This content has 5 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Ha egy Entry épp focus alatt van, és úgy választunk egy listaelemet a ListView-ből, az Entry Unfocus eventje nem fog triggerelődni. Ez azért van, mert a ListView a Touch eseményt ilyenkor elnyeli. Az én esetemben a megoldás ListView mögött egy háttérszínnel rendelkező grid volt, ami képes touch eventeket elkapni. A ListView InputTransparent tulajdonságának True-ra állításával ez a probléma megoldódott, mert az alatta lévő grid fókuszt kapott, és “mintha kikattintottunk volna” a gridből, az entry focusa megszűnt.

        <ListView
            x:Name="list"
            BackgroundColor="#393939"
            ItemTapped="list_ItemTapped"

            InputTransparent="True"

            ItemsSource="{Binding Path=AutoCompleteItems, Source={x:Reference UserControl}}"
            SelectedItem="{Binding Path=SelectedAddress, Source={x:Reference UserControl}}"
            SeparatorVisibility="None">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <usercontrols:AddressSelectorAutoCompleteItemDataTemplate />
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Próbáltam a ListView ItemSelectedjében unfocusolni az Entry Controlokat, azonban ez nem hozott sikert.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.