开发者

How to define datatemplates for datagrid?

开发者 https://www.devze.com 2023-02-14 01:23 出处:网络
This is probably a really basic question, but I\'m new to this and relying on Google searches, so... I\'m trying to put together a datagrid that displays rows of text containing an ID and multiple la

This is probably a really basic question, but I'm new to this and relying on Google searches, so...

I'm trying to put together a datagrid that displays rows of text containing an ID and multiple languages. I'm basing each row off a class "TextRow" that contains the ID and a collection of LanguageCell items, each containing the language and text (I plan to add more later):

    public class TextRowClass
    {
        public string Label { get; internal set; }
        public Dictionary<string, LanguageCell> TextCells { get; internal set; }

        public class LanguageCell
        {
            开发者_Python百科public string Language { get; internal set; }
            public string Text { get; internal set; }
        }
    }

My question is: How do I set up datagrid to display the information in the LanguageCell class as I want? (In this case, display the Text element in the cell and using other elements (to be added) for various other purposes.) I'm sure it has to do with defining a datatemplate, but I can't find any information about it.

Thanks!


I found the answer to this question in converting the class into a datatable and using that as my itemssource. In doing so, I ran across the problem that datagrids treat everything in the datatable as a datarowview, but this post solved that problem:

http://social.msdn.microsoft.com/Forums/en/wpf/thread/8b2e94b7-3c44-4642-8acc-851de5285062

Likely not the best or most elegant solution, but the only one I was able to find.

0

精彩评论

暂无评论...
验证码 换一张
取 消