Hi, I am trying to bind a DataGrid to an Array for testing purposes. As long as I am not trying to filter anything, the auto columns work nicely.
As soon as I try to filter the array by .Take(5) or any other filter, the rows stay empty, and there are only thing horizontal lines. I think it may have something to do, with the "anonymous" class generated by the Take. But this is a wild guess...
Let me show you some code which works nicely, and does what I want:
public partial class WindowLister : UserControl
{
private int counter = 0;
public WindowLister()
{
InitializeComponent();
dataGrid1.ItemsSource = SystemWindow.FilterToplevelWindows(filterFunction);
}
private bool filterFunction(SystemWindow window)
{
counter++;
if (counter > 5) return false;
return true;
}
}
And now the version which does not work:
public partial class WindowLister : UserControl
{
public WindowLister()
{
InitializeComponent();
dataGrid1.ItemsSource = SystemWindow.FilterToplevelWindows(filterFunction).Take(5);
}
private bool filterFunction(SystemWindow window)
{
return true;
}
}
For anyone interested, the Source used is from the very nice Lib: ManagedWinapi.Windows;
Any help is appreciated... Chris