PropertyChanged for indexer property

According to this blog entry, you have to use “Item[]”. Item being the name of the property generated by the compiler when using an indexer. If you want to be explicit, you can decorate the indexer property with an IndexerName attribute. That would make the code look like: public class IndexerProvider : INotifyPropertyChanged { [IndexerName … Read more

wpf bind to indexer

The quickest way to handle this is usually to use a MultiBinding with an IMultiValueConverter that accepts the collection and the index for its bindings: <TextBlock.Text> <MultiBinding Converter=”{StaticResource ListIndexToValueConverter}”> <Binding /> <!– assuming the collection is the DataContext –> <Binding Path=”Column.Index”/> </MultiBinding> </TextBlock.Text> The converter can then do the lookup based on the two values … Read more

“Strange” C# property syntax

It is an Indexer. Indexers allow instances of a class or struct to be indexed just like arrays. Indexers resemble properties except that their accessors take parameters. An indexer provides array-like syntax. It allows a type to be accessed the same way as an array. Properties such as indexers often access a backing store. We … Read more

Static Indexers?

I believe it was considered not to be terribly useful. I think it’s a shame too – an example I tend to use is Encoding, where Encoding.GetEncoding(“foo”) could be Encoding[“Foo”]. I don’t think it would come up very often, but aside from anything else it just feels a little inconsistent not to be available. I … Read more