Ivan
Ivan

Reputation: 1171

How to hide or gray out an item in a ListView?

As the title says :) I thought that I could access elements same as in a linked list, but I only found Items.GetItemAt(index). I would appreciate any help.

Upvotes: 1

Views: 488

Answers (1)

Glen Thomas
Glen Thomas

Reputation: 10764

If the items in the ListView are ViewModels, you can bind to a property (e.g. IsDisabled) and use that to trigger a style change to set a different opacity value.

<Image>
    <Image.Style>
        <Style TargetType="Image">
            <Setter Property="Opacity" Value="1"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsDisabled}" Value="True">
                    <Setter Property="Opacity" Value="0.5"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Image.Style>
</Image>

Upvotes: 2

Related Questions