本文介绍了结合双打的数组到DataGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图绑定双打的数组到DataGrid但网格不显示的双重价值。

I'm trying to bind an array of doubles to a datagrid but the grid does not show the values of the double.

我的格子看起来是这样的:

My grid looks like this:

<Grid>
  <DataGrid ItemsSource="{Binding}" AutoGenerateColumns="False" HorizontalAlignment="Stretch"
          Margin="5,5,5,5" Name="resultDataGrid1" VerticalAlignment="Stretch">
    <DataGrid.Columns>
      <DataGridTextColumn Header="Values" />
    </DataGrid.Columns>
  </DataGrid>
</Grid>

和在code后面我

private double[] _results = {0.012, 0.022};

...

resultDataGrid1.DataContext = _results;

的实际数据网格显示的行(2)的数量,但该细胞是所有emtpy。

The actual datagrid shows the number of rows (2) but the cells are all emtpy.

推荐答案

您必须告诉栏显示什么价值。既然你要显示该行的整体价值,用途:

You have to tell the column what value to display. Since you want to display the whole value of the row, use:

<DataGridTextColumn Header="Values" Binding="{Binding}" />

这篇关于结合双打的数组到DataGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 23:39