w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Combining AlternationIndex with Visibility in a style

A simple LINQ in the getter of your collection property would save you time instead of an UI oriented solution.. Here is how it would look like..

    private ObservableCollection<YourClass> _allDataItems;
    //The entire collection
    public ObservableCollection<YourClass> AllDataItems
    {
        get
        {
            return _allDataItems;
        }
        set
        {
            if( _allDataItems == value ) { return; }
            _allDataItems = value;
            if( _allDataItems != null )
            {
                _allDataItems.CollectionChangedEvent += ( s, e ) =>
                {
                    RaisePropertyChanged( "DisplayedDataItems" );
                };
            }
            RaisePropertyChanged( "AllDataItems " );
            RaisePropertyChanged( "DisplayedDataItems" );
        }
    }

    //The displayed colelction
    public ObservableCollection<YourClass> DisplayedDataItems
    {
        get
        {
            return AllDataItems.Where( adi => adi.ALIVE == true );
        }
    }

And you can simply bind DisplayedDataItems to your ListView.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.