macgile / DataGridFilter

WPF Filterable Datagrid, multi language
MIT License
379 stars 77 forks source link

System.Windows.Data Error with filtered columns on Pages #178

Open keeday opened 1 month ago

keeday commented 1 month ago

Hi,

Whenever I use the DataGridFilter within a page, that in turn is hosted within a frame, I get following errors

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=Background; DataItem=null; target element is 'SolidColorBrush' (HashCode=12781022); target property is 'Color' (type 'Color')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=Background; DataItem=null; target element is 'SolidColorBrush' (HashCode=28629874); target property is 'Color' (type 'Color')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=Background; DataItem=null; target element is 'SolidColorBrush' (HashCode=56342274); target property is 'Color' (type 'Color')

This only happens when a column have IsColumnFiltered="True"

From what I have been able to determine, it's that the filter popup is expecting a window to be the ancestor, when in my case, it's a frame / page.

Everything works fine visually and functionally, however, the biggest issue is that this seems to cause major performance issue during initialization. When I load the dataset I'm currently working with on a page, the loading time is roughly 13-17 seconds.

[13:45:17] [Info] [DataSetManagePage]: Page Loaded in 15.570 seconds.
[13:49:13] [Info] [DataSetManagePage]: Page Loaded in 13.860 seconds.
[13:51:14] [Info] [DataSetManagePage]: Page Loaded in 15.927 seconds.
[13:52:13] [Info] [DataSetManagePage]: Page Loaded in 17.931 seconds.
[13:52:57] [Info] [DataSetManagePage]: Page Loaded in 15.723 seconds.

When I use the exact same dataset and DataGrid setup in a window, the loading time is around 2-4 seconds.

[14:47:15] [Info] [DataSetManageWindow]: Window Loaded in 2.570 seconds.
[14:50:10] [Info] [DataSetManageWindow]: Window Loaded in 3.860 seconds.
[14:52:18] [Info] [DataSetManageWindow]: Window Loaded in 2.927 seconds.
[14:54:40] [Info] [DataSetManageWindow]: Window Loaded in 2.931 seconds.
[14:55:59] [Info] [DataSetManageWindow]: Window Loaded in 3.723 seconds.

There's no difference between the page and the window, other than that the window is a window, and the page is a page hosted within a frame.

macgile commented 1 month ago

Hi, It can't get the popup window background color from the parent (windows) try to set the "FilterPopupBackground " property of Filterdatagrid. It can't find the "Window" object because you are using a page. do the test and tell me if the error still appears.

I didn't plan to use the pages as a parent.

keeday commented 1 month ago

Hi, It can't get the popup window background color from the parent (windows) try to set the "FilterPopupBackground" property of Filterdatagrid. It can't find the "Window" object because you are using a page. do the test and tell me if the error still appears.

I didn't plan to use the pages as a parent.

Hi,

Yes, sorry I forgot to mention, FilterPopupBackground is set, and makes not difference in regards to the errors.

It sets the background fine, and everything seems to function as intended both visually and functionally. The issue ends up being that performance takes a big hit during initialization of the DataGrid when in a page.

macgile commented 3 weeks ago

Hi, I (maybe) found a solution to fix the "background" property bug, I'll commit it soon. However, using "Page" does not cause errors.

keeday commented 2 weeks ago

Hi, I (maybe) found a solution to fix the "background" property bug, I'll commit it soon. However, using "Page" does not cause errors.

Strange. I will try to replicate the issue in a fresh project. I should not have anything that would interfere, but it might be worth checking.