using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;

namespace SilverlightApplication45
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {        
            this.InitializeComponent();
            testGrid.ItemsSource = new List<MyClass>() { new MyClass() { Field1 = 2, Field2 = 3 }, new MyClass() { Field1 = 0, Field2 = 3 }, new MyClass() { Field1 = 3, Field2 = 1 } };
            testGrid.SelectionChanged += new EventHandler<SelectionChangeEventArgs>(testGrid_SelectionChanged);
        }

        void testGrid_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            GridViewRow oldRow = new GridViewRow();
            GridViewRow newRow = new GridViewRow();
            if ((e.RemovedItems.Count > 0 ? e.RemovedItems[0] : -1) as MyClass != null)
            {
                oldRow = testGrid.ItemContainerGenerator.ContainerFromItem(e.RemovedItems.Count > 0 ? e.RemovedItems[0] : -1) as GridViewRow;
                oldRow.DetailsVisibility = Visibility.Collapsed;
            }
            newRow = testGrid.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0]) as GridViewRow;
            newRow.DetailsVisibility = Visibility.Visible;
        }

    }

    public class MyClass
    {
        public int Field1 { get; set; }
        public int Field2 { get; set; }

        public MyClass()
        {

        }
    }
}
