Home Forums WPF controls Xceed DataGrid for WPF How to insert a Listbox inside a grid cell with xml binding

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #27056 |

    Hi [:)], I´m trying to insert a listbox into a cell, but still I couldn´t.

    I´m loading a xml like this

    StringBuilder

    data = new StringBuilder();

    data.Append(“<r>”);

    data.Append(”   <name>William</name>”);

    data.Append(”   <p>”);

    data.Append(”    <n>name1</n>”);

    data.Append(”    <v>value1</v>”);

    data.Append(”   </p>”);

    data.Append(”   <p>”);

    data.Append(”    <n>name2</n>”);

    data.Append(”    <v>value2</v>”);

    data.Append(”   </p>”);

    data.Append(“</r>”);

    xml.LoadXml(data.ToString());

    this

    .DataContext = xml;

     

    I would like to render a Grid with one column binded to the “name” node and other column to a list of “p” nodes, where I want to show a listbox in that columns showing the diferents values of the nodes “n” and “v”..

    I was trying to do this by difrents ways but I couldn´t. Can you help me?

    Thanks!

    Imported from legacy forums. Posted by Guille (had 1435 views)

    Xceed Support
    Member
    Post count: 5658

    XML data is currently not 100% supported by the grid. That said, you could refer to this thread to get an idea of how to proceed.

    As for display the values of 2 subnodes in a cell, I suggest you create a new DataTemplate that consists of a Panel and 2 TextBlocks whose Text properties are bound to the n and v nodes. This template should then be provided to the column’s CellContentTemplate property. Something like:

    <xcdg:DataGridControl.Columns>
       <xcdg:Column FieldName=”p”>
          <xcdg:Column.CellContentTemplate>
             <DataTemplate>
                <StackPanel>
                   <TextBlock Text=”{Binding Path=n}”/>
                   <TextBlock Text=”{Binding Path=p}”/>
                </StackPanel>
             </DataTemplate>
          </xcdg:Column.CellContentTemplate>
       </xcdg:Column>
    </xcdg:DataGridControl.Columns>

    Of course this assumes that you implemented the details in the first thread regarding XmlDataGridItemProperty objects. 

    Imported from legacy forums. Posted by Jenny [Xceed] (had 1728 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.