WPF Datagrid items binding problem

Posted by gencay on Stack Overflow See other posts from Stack Overflow or by gencay
Published on 2010-12-28T00:51:46Z Indexed on 2010/12/28 0:53 UTC
Read the original article Hit count: 262

Filed under:

I get a problem while displaying a List in WPF-Datagrid. When I do this line

...
DocumentList dt = new DocumentList(fileWordList, fileUriType, fileUri, cosineSimilarityRatio, diceSimilarityRatio, extendedJaccardSimilarityRatio);
documentList.Add(dt);
...
dataGrid1.Items.Add(dt);
...

It creates an empty row into dataGrid1 and no text is shown there.

my xaml implementation is this:

<GroupBox Canvas.Left="-0.003" Canvas.Top="0" Header="Display Results" Height="427.5" Name="groupBox2" Width="645.56">
            <toolkit:DataGrid Canvas.Left="137.5" Canvas.Top="240" Height="392" Name="dgrDocumentList" Width="627" ItemsSource="{Binding DocumentList }">
                <toolkit:DataGrid.Columns>
                    <toolkit:DataGridTextColumn Header="Type" Binding="{Binding type}" IsReadOnly="True">
                    </toolkit:DataGridTextColumn>
                    <toolkit:DataGridHyperlinkColumn Header="Uri" Binding="{Binding path}" IsReadOnly="True">

                    </toolkit:DataGridHyperlinkColumn>
                    <toolkit:DataGridTextColumn Header="Cosine" Binding="{Binding cos}" IsReadOnly="True">

                    </toolkit:DataGridTextColumn>
                    <toolkit:DataGridTextColumn Header="Dice" Binding="{Binding dice}" IsReadOnly="True">

                    </toolkit:DataGridTextColumn>
                    <toolkit:DataGridTextColumn Header="Jaccard" Binding="{Binding jaccard}" IsReadOnly="True">

                    </toolkit:DataGridTextColumn>
                </toolkit:DataGrid.Columns>
            </toolkit:DataGrid>
        </GroupBox>

and my DocumentList class

class DocumentList
{
    public List<WordList> wordList;
    public string type;
    public string path;
    public double cos;
    public double dice;
    public double jaccard;
    //public static string title;

    public DocumentList(List<WordList> wordListt, string typee, string pathh, double sm11, double sm22, double sm33)
    {
        type = typee;
        wordList = wordListt;
        path = pathh;
        cos = sm11;
        dice = sm22;
        jaccard = sm33;
    }

I would like to do that: When i add a new element into documentList instance, would like to see the results on data grid. Thank you in advance.

© Stack Overflow or respective owner

Related posts about wpf