This is probably a very stupid question, but I just cant figure it out.
Assuming that I have a data structure represented by these two classes:
class Accessor
{
}
class Row : INotifyCollectionChanged
{
public object this[Accessor index] {get;}
}
And if I also have a view-model like this:
class ViewModel
{
public Row CurrentRow{get;}
public Accessor CurrentAccessor {get;}
}
How can I define CurrentRow[CurrentAccessor] binding in XAML? I have tried using
{Binding Path=CurrentRow[{Binding Path=CurrentAccessor}]}, but this doesn’t seem to work.
Update: I should point out that Row class is a collection that implements INotifyCollectionChanged interface, so using a simple property wrapper like this
public object WrappedProperty { get{return CurrentRow[CurrentAccessor];}} wouldn’t work since then there will be no updates if the values stored in CurrentRow[CurrentAccessor] changes.
You might change your Binding into a MultiBinding with an appropriate converter:
The converter might look like this: