简体   繁体   English

针对多个索引值的PropertyChanged

[英]PropertyChanged for multiple index values

To raise a PropertyChanged event for an indexer and a particular index value, do this: 要为索引器和特定的索引值引发PropertyChanged事件,请执行以下操作:

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? 而不是Item[{0}] ,格式字符串应该是什么样? Is it Item[{0},{1},{3}] or perhaps Item[{0}][{1}][{3}] ? Item[{0},{1},{3}]还是Item[{0}][{1}][{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. 我有一些类似的地方,我将多个值传递给预订了OnPropertyChanged的函数,只是使用一些char来解析项目。

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 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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