开发者

ValidationRule with Indexer Issue

开发者 https://www.devze.com 2023-04-04 07:24 出处:网络
Our company is using indexers for our framework, so that we ca开发者_Go百科n quickly bind data to a window without having to create a property for each data source. Since WPF (unlike Silverlight?) req

Our company is using indexers for our framework, so that we ca开发者_Go百科n quickly bind data to a window without having to create a property for each data source. Since WPF (unlike Silverlight?) requires you to use OnPropertyChanged("Item[]") to indicate a change, all items that use an indexer are refreshed on the UI. This functionality causes a problem when a control uses both a ValidationRule and accesses the data through an indexer. It seems that in calling the OnPropertyChanged for an indexer property, it refreshes the data on the control to what is in the data source when there is an error with the control. Since there is not a way to call OnPropertyChanged for a indexer property with a key value, a change to another control ends up reverting what is in the control that has the error.

My question is: Has anyone been able to use both indexer properties and ValidationRule, together, such that a control with an error keeps its error until the user fixes the control?

If not, does anyone have any suggestions? We like using the indexer property, since this makes setting up binding much quicker than creating a property for every data field (our applications are centered around CRUD).


The solution, that was found, was to implement a DynamicObject. Doing this removed the indexer from being used, and sidestepped the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消