ユーザーがグリッド形式で整列されたグラフのコレクションを視覚化できるようにする、WPF アプリケーションの UI 要素を構築しています。私が理解しているように、UI要素をグリッド形式で適切に配置するWrapPanelでItemsControlを使用できます。
Winforms グラフ作成ライブラリ (zedgraph) を使用してグラフを生成しようとすると、問題が発生します。これはWindowsFormsHost
、グラフ ビューを表示するために を使用する必要があることを意味します。通常のデータバインディングを使用してグラフコレクションをバインドしようとしましたが、実際には機能しません:
XAML:
<ItemsControl ItemsSource="{Binding Graphs}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<WindowsFormsHost Margin="5">
<ui:Graph></ui:Graph>
</WindowsFormsHost>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
上記のコードは何も表示しませんが、Graphs ゲッターがアクセスされます。
また、バインドをキャンセルして、ItemsControl 内にランダムなグラフ ビューを挿入しただけでも、何も表示されません。
XAML:
<ItemsControl>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<WindowsFormsHost Margin="5">
<ui:Graph></ui:Graph>
</WindowsFormsHost>
<WindowsFormsHost Margin="5">
</WindowsFormsHost>
<ui:Graph></ui:Graph>
</WindowsFormsHost>
<WindowsFormsHost Margin="5">
<ui:Graph></ui:Graph>
</WindowsFormsHost>
</ItemsControl>
グラフ作成ライブラリが正常に機能することをテストするために、これは実際にグラフを表示します。
<Grid>
<WindowsFormsHost Margin="5">
<ui:Graph></ui:Graph>
</WindowsFormsHost>
</Grid>
誰かが私を正しい方向に導くことができますか? とても有難い。