Home Forums WPF controls Xceed DataGrid for WPF Custom Row in Fixed Footer

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

    Hi I am trying to add a row in the fixed footer to display additional information about each column. This would be used to show a text description of the column. Here is what I have so far:

    <xcdg:TableView.FixedFooters>
    <xcdg:ClearHeadersFooters/>
    <DataTemplate>
    <xcdg:DataRow Style=”{StaticResource FooterStyle}” Name=”MyFooterRow”/>
    </DataTemplate>
    </xcdg:TableView.FixedFooters>

    This gives me a row with a different style that matches the columns in my table.
    I need to know how to fill the cells in this row wth content (bound or unbound).

    I was hoping I could do something like this:

    <xcdg:TableView.FixedFooters>
    <xcdg:ClearHeadersFooters/>
    <DataTemplate>
    <xcdg:DataRow Style=”{StaticResource FooterStyle}” Name=”MyFooterRow”> <xcdg:DataRow.Cells>
    <xcdg:DataCell Content=”Show Something Here”/>

    <!– More Cells here –>
    </xcdg:DataRow.Cells>
    </xcdg:DataRow>
    </DataTemplate>
    </xcdg:TableView.FixedFooters>

    I think the StatRow does something similar, only displaying statistical info instead. I would like the same kind of layout but without using the “Pro” requirements. Any suggestions?

    Imported from legacy forums. Posted by pin_monkey12 (had 3043 views)

    User (Old forums)
    Member
    Post count: 23064

    I made some progress.
    I have added a DataCell Style to the resources of of the DataRow and have set the DataContext of the DataRow to “ABC” for now, this will eventually be some kind of data resource.

    The DataCell style lets me set the template of all the cells in the footer.
    The template has all the cells in the footer containing a TextBlock with the text property set to {Binding}. This makes all the footer cells show the string “ABC”.

    Once I change the DataContext to a set of descriptions, how do I pick a different value for each cell. Right now the cells are all using this style:

    <xcdg:TableView.FixedFooters>

    <xcdg:ClearHeadersFooters/>
    <DataTemplate>
    <xcdg:DataRow Style=”{StaticResource FooterStyle}” Name=”MyFooterRow” DataContext=”ABC”>
    <xcdg:DataRow.Resources>
    <Style TargetType=”{x:Type xcdg:DataCell}” >
    <Setter Property=”Template”>
    <Setter.Value>
    <ControlTemplate>
    <TextBlock>
    <TextBlock.Text>
    <Binding/>
    </TextBlock.Text>
    </TextBlock>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </xcdg:DataRow.Resources>
    </xcdg:DataRow>
    </DataTemplate>

    </xcdg:TableView.FixedFooters>

    The problem I’m facing is that I can’t set different bindings for each cell. The only thing I can think of is using a converter to convert the collection to an individual item in the collection. The converter would have to take a parameter which specifies which element in the collection to return.
    Is there any way I can do this and somehow pass in the cell’s column index as a converter parameter?

    Imported from legacy forums. Posted by pin_monkey12 (had 407 views)

    User (Old forums)
    Member
    Post count: 23064

    More Progress…

    I have removed the DataContext of the DataRow.
    Instead I added a converter to the Binding on the TextBlock.

    The binding now looks like:

    <Binding Converter=”{StaticResource CellConverter}”
    RelativeSource=”{RelativeSource TemplatedParent}”
    ConverterParameter=”{StaticResource TableData}” />

    RelativeSource TemplatedParent means the converter will get the cell object as the value parameter.
    ConverterParameter TableData allows for some additional kind of data source (TableData) to be passed in to the converter. In this case it could be an XML document with a bunch of descriptions.

    CellConverter is a converter that will take the DataCell, passed in as value, get the DataCell FieldName, use that fieldname to find a description in the DataSource (passed in as the parameter), and return that value as a string which will display a unique description in each footer cell.

    Imported from legacy forums. Posted by pin_monkey12 (had 652 views)

    Xceed Support
    Member
    Post count: 5658

    Probably that the easiest way to achieve this is to create you own simple row type…

    Effectively, the DataRow class is a class that specialize in binding to a data item through the use of DisplayMemberBindings.

    Starting from the Row base class (which does not have such a specialization), you can easilly achieve what you are looking for:

    the simple class would go as follows:

    <code>
    public class CustomRow : Row
    {
    protected override Cell CreateCell(Column column)
    {
    return new Cell();
    }

    protected override bool IsValidCellType(Cell cell)
    {
    return (this.GetType() == typeof( Cell ) );
    }
    }
    </code>

    you can then use that class as follows in the [Fixed]Headers/Footers:

    <code>
    <DataTemplate>
    <local:CustomRow>
    <xcdg:Cell FieldName=”Column1″ Content=”Description for Column1″ />
    <xcdg:Cell FieldName=”Column2″ Content=”Description for Column2″ />
    <xcdg:Cell FieldName=”Column3″ Content=”Description for Column3″ />
    </local:CustomRow>
    </DataTemplate>
    </code>

    Imported from legacy forums. Posted by Marcus [Xceed] (had 4132 views)

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