我正在为我们的WPF应用程序构建一个UI元素,它允许用户以网格格式可视化一组图表。据我了解,您可以使用带有WrapPanel的ItemsControl来很好地对齐UI元素以网格格式显示。
当我们尝试使用winforms图形库(zedgraph)生成图形时,问题就出现了。这意味着我们必须使用
XAML:
上面的代码没有显示任何内容,但是Graphs getter被访问了。
此外,即使我取消绑定并且只在ItemsControl中插入一些随机图形视图...它仍然不会显示任何内容:
XAML:
为了测试图形库的正常功能,确实会显示一个图形:
有人能引导我正确的方向吗?非常感谢。
当我们尝试使用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 getter被访问了。
此外,即使我取消绑定并且只在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>
有人能引导我正确的方向吗?非常感谢。
Width
和Height
值。 - Federico Berasategui