【问题标题】:OxyPlot in ListView WPF deos not display anythingListView WPF deos 中的 OxyPlot 不显示任何内容
【发布时间】:2015-08-03 21:11:01
【问题描述】:

如果我使用:

<oxy:PlotView  MinHeight="260" Height="Auto"   IsRendering="True" FontStyle="Normal" FontFamily="Arial" FontSize="8" Model="{Binding PlotM}">
                        </oxy:PlotView>

它正确显示了绘图。

如果我使用此代码:

<ListView Name="PlotLista"  ItemsSource="{Binding PlotModelList}" >
    <ListView.ItemTemplate>
        <DataTemplate>
           <StackPanel>
              <oxy:PlotView  MinHeight="260" Height="Auto"   IsRendering="True" FontStyle="Normal" FontFamily="Arial" FontSize="8" Model="{Binding}">
              </oxy:PlotView>
            </StackPanel>
         </DataTemplate>
      </ListView.ItemTemplate>
</ListView>

它显示了一个 bkank 元素列表,并且没有显示 OxyPlot。 PlotModelList 是List&lt;PlotModel&gt;

【问题讨论】:

  • Model="{Binding},应该是 Model="{Binding PlotM}" 吗?
  • 不,PlotM 是 PlotModel 而 PlotModelList 是 List
  • 您正在设置 PlotView 元素的 MinHeight。它是否可能还需要 Width 或 MinWidth,或者至少需要 ListViewItem 样式中的 HorizontalContentAlignment=Stretch 之类的东西?
  • 或者尝试绑定到ObservableCollection&lt;PlotModel&gt;,而不是List&lt;PlotModel&gt;。如果List&lt;PlotModel&gt; 在绑定之后 被填充,您的ListView 将不会被通知列表中的更改并且它将保持为空。

标签: c# wpf oxyplot


【解决方案1】:

问题是宽度和高度:

     <ListView Name="PlotLista"  ItemsSource="{Binding PlotModelList}" >
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <oxy:PlotView  MinHeight="260" Height="Auto" HorizontalContentAlignment="Stretch" MinWidth="700"   IsRendering="True" 
FontStyle="Normal" FontFamily="Arial" FontSize="8" Model="{Binding}">
                                </oxy:PlotView>
                                </StackPanel>
                            </DataTemplate>
                        </ListView.ItemTemplate>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    相关资源
    最近更新 更多