HappyNomad
HappyNomad

Reputation: 4548

PropertyChanged for multiple index values

To raise a PropertyChanged event for an indexer and a particular index value, do this:

OnPropertyChanged(string.Format(CultureInfo.CurrentCulture, "Item[{0}]", indexValue));

But what if the indexer accepts multiple index values? Rather than Item[{0}], what should the format string look like? Is it Item[{0},{1},{3}] or perhaps Item[{0}][{1}][{3}]?

Upvotes: 0

Views: 138

Answers (1)

Adam Rodriguez
Adam Rodriguez

Reputation: 3

I've had something similar where I passed in multiple values to a function that was subscribed to OnPropertyChanged and just used some char to parse the items.

If I understand correctly you're just trying to get those values correct?

You could do:

 OnPropertyChanged(string.Format(CultureInfo.CurrentCulture, "Item[{0}];Item[{1}];Item[{2}]", indexValue, indexValue1, indexValue2));

Then just parse on ; using:

string[] stringArray = yourString.Split(';')

Hope that helps

Upvotes: 0

Related Questions