テスト用にDataGridを配列にバインドしようとしています。 フィルターをかけようとしていない限り、自動列はうまく機能します。WPF DataGrid Take()がItemsSourceで機能しない
.Take(5)やその他のフィルタで配列をフィルタリングしようとすると、行は空のままであり、水平線のみが存在します。私はそれが何かを持っているかもしれないと思う、Takeによって生成された "匿名の"クラスで。しかし、これは野生の推測です...
は、私はあなたにうまく動作いくつかのコードをお見せしましょう、と私が欲しいものを行います。
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;
}
}
そして今は動作しませんバージョン:
public partial class WindowLister : UserControl
{
public WindowLister()
{
InitializeComponent();
dataGrid1.ItemsSource = SystemWindow.FilterToplevelWindows(filterFunction).Take(5);
}
private bool filterFunction(SystemWindow window)
{
return true;
}
}
関心のある方は、使用しているソースは非常に素晴らしいLib:ManagedWinapi.Windowsからです。
すべてのヘルプは高く評価され... クリスは
パーフェクト...私はこのサイトが大好きです:-)ありがとう! –