Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

DataGrid footer RSS

4 replies

Last post Jun 30, 2009 02:35 PM by raz0rf1sh

(0)
  • novy

    novy

    Member

    2 Points

    18 Posts

    DataGrid footer

    Dec 10, 2008 07:34 AM | LINK

    I want to add footer to datagrid control for example to show number of rows in datagrid.

    Is the only way to create new control template?

     

  • silverbyte

    silverbyte

    Participant

    1392 Points

    482 Posts

    Re: DataGrid footer

    Dec 10, 2008 08:08 AM | LINK

     why don't you just create a UserControl with a StackPanel holding DataGrid and a simple TextBlock:

    <UserControl ... >

       <StackPanel Orientation="Horizontal">

                <data:DataGrid>

                         ....

                </data:DataGrid>

                <TextBlock x:Name="footer" />

       </StackPanel>

    </UserControl>


    you can compute and set the text of the footer in code

    Please click on 'Mark as answer' near my comment if you feel I answered your question.
  • novy

    novy

    Member

    2 Points

    18 Posts

    Re: DataGrid footer

    Dec 12, 2008 12:05 PM | LINK

    In this case,  If I set DataContext to some collection on my UserControl how should I set Text property on TextBlock.

    Is this ok?

    <TextBlock x:Name="footer"  Text={Binding Path=Count}/>

  • yifung

    yifung

    Contributor

    3937 Points

    637 Posts

    Microsoft

    Re: DataGrid footer

    Dec 13, 2008 12:23 AM | LINK

    Sure, as long as there's a public Count property on your collection and you set the DataContext of the TextBlock to it

    Yifung Lin [MSFT]
  • raz0rf1sh

    raz0rf1sh

    Member

    6 Points

    6 Posts

    Re: DataGrid footer

    Jun 30, 2009 02:35 PM | LINK

    Any luck with this? You'd think they would just expose a FooterTemplate or something along those lines.