expand/collpase datagrid

Posted by prince23 on Stack Overflow See other posts from Stack Overflow or by prince23
Published on 2010-05-13T11:22:51Z Indexed on 2010/05/13 11:54 UTC
Read the original article Hit count: 455

hi,

i have an nested datagrid . i able to bind the values with no issues once i clik teh row i able to show nested grid.

now i need to add an image button( like an "+ " Symbol ) at the left corner. once i press this button the grid shows the further records under it. that time i need to repalce the image button with ("--" symbol). i have these two images done.

but how to do this is really a big issue now for me.can any one help me out.struck on this issue from past 3 days.

plz plz provide an solution on this.

i would be really thank full for you guys . am new to silver light

this is my code.

<sdk:DataGrid MinHeight="100" x:Name="dgCounty" AutoGenerateColumns="False" VerticalAlignment="Top" Grid.Row="1"   IsReadOnly="True"  Margin="5,5,5,0" RowDetailsVisibilityChanged="dgCounty_RowDetailsVisibilityChanged"  RowDetailsVisibilityMode="VisibleWhenSelected">
            <sdk:DataGrid.Columns>

                <sdk:DataGridTemplateColumn  CanUserReorder="False">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="+" Click="Button_Click"></Button>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTextColumn Header="ID" Width="100" Binding="{Binding EmployeeID}" CanUserReorder="False"/>
                <sdk:DataGridTextColumn Header="FirstName" Width="80" Binding="{Binding EmployeeFName}" CanUserReorder="False"/>
                <sdk:DataGridTextColumn Header="LastName" Width="80" Binding="{Binding EmployeeLName}" CanUserReorder="False"/>
                <sdk:DataGridTextColumn Header="MailID" Width="80" Binding="{Binding EmployeeMailID}" CanUserReorder="False"/>

            </sdk:DataGrid.Columns>
            <sdk:DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <sdk:DataGrid x:Name="dgrdRowDetail" Width="400" AutoGenerateColumns="False" HorizontalAlignment="Center" IsReadOnly="True" >
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn  Header="CompanyName" Binding="{Binding CompanyName}"/>
                            <sdk:DataGridTextColumn  Header="CompanyID" Binding="{Binding CompanyID}"/>
                            <sdk:DataGridTemplateColumn  Header="Score">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate >
                                        <StackPanel Loaded ="StackPanel_Loaded" Orientation="Horizontal" Background="Transparent">
                                            <TextBlock Text="{Binding Score}" TextWrapping="NoWrap" HorizontalAlignment="Center" Foreground="Blue"></TextBlock>
                                            <!--<Image Source ="../Images/image1.JPG" Width="20" Height="20" Stretch ="Fill"/>-->
                                            <Image x:Name="imgScore" Source ="{Binding Score}" Width="20" Height="20" Stretch ="Fill"/>
                                            <sdk:Label Content="Score" />
                                        </StackPanel>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>


  private void Button_Click(object sender, RoutedEventArgs e)
        {

//how  to handle this issue.

}  

if possiable plz provide the code that can help me out.

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about silverlight-4.0