Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

XAML: Disabling a button when ListView.SelectedItem property is NULL

$
0
0

Hi,

I want to disable a button when SelectedItem property of ListView is null. I tried this:

<Button Clicked="myButton_Clicked" Image="ic_image" x:Name="myButton">
    <Button.Style>
        <Style TargetType="Button">
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=myListView, Path=SelectedItem}" Value="{x:Null}">
                    <Setter Property="IsEnabled" Value="false" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Button.Style>
</Button>

The app has a login page and a main page. Login credentials are stored on the device. If everything goes well, main page appears otherwise login page appears.

If I comment out this part:

                ...
                <DataTrigger Binding="{Binding ElementName=myListView, Path=SelectedItem}" Value="{x:Null}">
                    <Setter Property="IsEnabled" Value="false" />
                </DataTrigger>
                ...

main page appears but if I uncomment that part, login page appears. I think that part causes an error but the IDE (VS Mac) doesn't throw it. Could anyone help me?

Thank you...


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>