This is a migrated thread and some comments may be shown as answers.

expand/collpase issue in nested data grid.

0 Answers 24 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kumar p
Top achievements
Rank 1
kumar p asked on 26 May 2010, 11:26 AM

 hi,
in nested data grid    for the  second gridview   i have  an  button where i am performing expand/collpase
  for the datagrid 1 the   below   event  works  fine

 private void btn1_Click(object sender, RoutedEventArgs e)
        {
            try
            {              
                Button btnExpandCollapse = sender as Button;
                Image imgScore = (Image)btnExpandCollapse.FindName("imgLevel1");
                DependencyObject dep = (DependencyObject)e.OriginalSource;
                while ((dep != null) && !(dep is GridViewRow ))
                {
                    dep = VisualTreeHelper.GetParent(dep);
                }

                // if we found the clicked row
                if (dep != null && dep is GridViewRow)
                {
                    // get the row
                    GridViewRow row = (GridViewRow)dep;                  
                    if (row.DetailsVisibility  == Visibility.Visible)
                    {
                        imgScore.Source = new BitmapImage(new Uri("/Images/left_side.png", UriKind.Relative));                     
                        row.DetailsVisibility = Visibility.Collapsed;                    
                    }
                    else
                    {
                        imgScore.Source = new BitmapImage(new Uri("/Images/down_side.png", UriKind.Relative));
                        row.DetailsVisibility = Visibility.Visible;
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }

 for the second datagrid    i have an same  function as  above  with different name i am getting exception  at this line.
 
                    if (row.DetailsVisibility  == Visibility.Visible)
                    {               
                        row.DetailsVisibility = Visibility.Collapsed;                    
                    }
                    else
                    {
                        row.DetailsVisibility = Visibility.Visible;
// getting  exception at this  line.
Failed to create a 'System.Windows.Style' from the text 'None'.

                    }


 any  solution on this  would be  greatly appreciated.
 thanks
 kumar

No answers yet. Maybe you can help?

Tags
GridView
Asked by
kumar p
Top achievements
Rank 1
Share this question
or