Is it possible to bind a variable to a collection item

I am trying to bind an element inside a collection, but the index for this element should be "variable". Take the following pseudo syntax, for example:

<TextBlock Text="{Binding Fields[{Binding Pos}]}" />

Is something like this possible? If my Pos property is 1, it should bind to the first item from the Fields collection, and if my Pos is 3, it should bind to the third item in the collection. I simplified my problem in this situation ...

Something like this is doable and how?

+5
source share
3 answers

, . , . :

<TextBlock Text="{Binding Fields, 
                  Converter={StaticResource CollectionToItemConverter,
                  ConverterParameter={Binding Pos}}}" />

, .

, .

+5

ICollectionView... , .

+1

, WPF?

:

class myCollection
{

    private string _current;

    public string CurrrentField
    {
         get { return _current; }
    }

    // TODO: Set current item to whatever the current item is...
}

EDIT:

, , , , , , .

, , , , ..

, .

0

All Articles