Hi,
Our team noticed that when a field in a XamDataGrid record is bound to a property that returns null, that property's setter gets re-evaluated multiple times when the record is loaded and also re-evaluates when the mouse hovers over the record.
This is having some very negative and adverse behavior for us since the grid control seems to be making an assumption about what null means, but from the data standpoint its a legitimate value. Yet, the grid doesn't treat it like any other value.
The only workaround I've found is to specify AlternateBinding with AlternateBindingRetentionMode="Retain". However, we have dozens of grids with hundreds of fields already declared, and it will be a massive PITA to go and migrate the field declarations for each.
1. Why does the grid re-evaluate fields that are null? Is this by design?2. Can this behavior be set on a global level so that alternate binding isn't specified?Thanks,BedoHere is a sample app that demonstrates the behavior: Simply brake where DoubleNullable and ObjectNull's getters return. Then run and move the mouse over the grid.
---- XAML -----
<Window x:Class="WpfApplication1.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:dataPresenter="http://infragistics.com/DataPresenter"Title="MainWindow" Height="350" Width="525"><dataPresenter:XamDataGrid DataSource="{Binding Items}"/></Window>
---- CODE ----
using System.Collections.ObjectModel;using System.Windows;
namespace WpfApplication1 {public partial class MainWindow : Window {public MainWindow() {InitializeComponent();DataContext = new TestViewModel();}}
public class TestViewModel {public ObservableCollection<Item> Items { get; private set; }public TestViewModel() {Items = new ObservableCollection<Item> { new Item() };}}
public class Item {public double Double1 { get { return 1; } }public double DoubleNaN { get { return double.NaN; } }public double? DoubleNullable {//This gets called multiple times when the mouse hovers over the recordget { return null; }}
public object Object { get { return new object(); } }public object ObjectNull {//This gets called multiple times when the mouse hovers over the recordget { return null; }}
}}
Hello Bedo,
Thank you for your post.
I have been looking into it and the code snippet that you have provided. I created a short sample application based on your code and I could not manage to reproduce the issue that you have. Also I created a short video to show you how it works on my side Would you please modify the attached sample application with the functionality you are using. This way I would be able to further investigate this for you and provide you with more detailed information on this matter.
Looking forward to hearing from you.
Hi Zhivko,
With your exact example, I am still seeing the null issue. My breakpoints get hit. I've made absolutely no changes to your example. Perhaps the issue may be tied to the exact version of the assemblies?
I'm using:
Runtime Version: v4.0.30319
InfragisticsWPF4.DataPresenter.v14.2 14.2.20142.2081InfragisticsWPF4.Editors.v14.2 14.2.20142.2081InfragisticsWPF4.v14.2 14.2.20142.2081