简体   繁体   中英

Excluding first index item from a list and bind the rest to a listbox

I have a ObservableCollection<> of images(byte) and title(string). I want it to bind to two different GRID: GridA and GridB. In GridA, I have an image control to which I want to bind the image in the index[0] of the collection and in GridB, an image listbox is there to which I want the remaining item from the collection ie excluding index[0].

How can I get this?

I'd create separate properties on the ViewModel which contain what you want and bind each grid to them.
Something like:

public Image GridAContent
{
    get
    {
        return this.Items.First();
    }
}

public ObservableCollection<Image> GridBContent
{
    get
    {
        return this.Items.Skip(1);
    }
}

Assuming that your current observable collection is called Items .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM