In WPF 4 the binding expression list on the binding group, which is passed to the ValidationRule
's Validate method, is empty.
It is the same whether AutoGenerateColumns
is true or false, whether DataGridBoundColumns
explicitly has been added to the datagrid.
In WPF 3.5 SP1 using the DataGrid
from the Toolkit the binding expression list is filled with the excepted binding expressions (1 for each column in the data grid)
I consider this a bug and has posted it on the Microsoft Connect site: https://connect.microsoft.com/WPF/feedback/details/642815/bindingexpressions-on-bindinggroup-passed-to-validationrule-in-datagrid-rowvalidationrules-is-empty
But does anyone have a workaround so I can get the correct binding expression from within the ValidationRule
?
In order to support "proposed values" that are not committed to the target of a two-way binding until validation succeeds, the WPF 4.0 DataGrid
was redesigned to take advantage of the the new BindingGroup.SharesProposedValues
feature of WPF 4.0. Because of this change, it is no longer necessary to use two-way bindings in binding group of display templates.
You can use BindingGroup.TryGetValue
to retrieve the proposed values for other columns instead of using the old method that worked with the DataGrid
from the WPF Toolkit.
In other words, the new DataGrid
actually fixes an undesirable feature of the old DataGrid
and as a result things work slightly differently (i.e. the missing bindings are by design) but you can still do what you need to do.
The explanation in Microsoft's own words is in this Microsoft Connect link:
And here is a blog that describes BindingGroup.SharesProposedValues
in another way:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With