Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Trying to figure out why public virtual string this[string propertyName] is repeatedly called

$
0
0

Hi all,

I am trying to implement INotifyPropertyChanged, IDataErrorInfo in a class and having some minor issues.  I borrowed some code from the web and in the process of testing it (the authors source) to figure out how this all works, found an interesting issue.

It appears that when I have:

public virtual string this[string propertyName] { get { ....

It gets called many times in a given refresh (i.e. I would expect it to be called once.)  The problem is that I can't step through the code because it's all .NET. 

I don't want to bother you with the code as I didn't write it and don't want to have to explain why the author did what they did.

What I am trying to find out is: What syntax will trigger that to be called?

I can't find any documents on what causes that to be called (it is hard because I can't search for stuff with brackets.)

Essentially, I want to be able to look up the property in an array of rules and execute any delegates (validation rules) associated with that property. 

The code works fine except for the repeated calls.  In the sample form, it's no big deal, but some of the forms I will be working with will have a large number of fields with lots of validations.  Having it test every property 8 times BEFORE the form is rendered strikes me as a possible performance hit.

My guess is that in my validation code or whatever, I am accidently referencing something that is causing that to be called again.  But in the call stack I don't see the repeated calls being called hierarchically, but serially.  So it goes through all the properties, then starts over (8 times.)

Any ideas?

Thanks!


me (and yes, I DO mark correct answers)


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>