3

ユーザーがグリッド形式で整列されたグラフのコレクションを視覚化できるようにする、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> 

誰かが私を正しい方向に導くことができますか? とても有難い。

4

1 に答える 1

2

それはレイアウトに関係している可能性があります。winforms は恐ろしく、すべてのサイズをハードコーディングする必要があります。

ハードコードされた固定幅と高さを winformshost に指定してみてください

于 2013-10-18T14:32:19.577 に答える