protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            // Provide a way for the cell's AutomationProviders to
            // know their ContaingGrid, and what row they're in.
            MyGridData data = item as MyGridData;

            if (data != null)
            {
                ListViewItem lvItem = element as ListViewItem;
                if (lvItem != null)
                {
                    AutomationProperties.SetLocalizedControlType(lvItem, "Row");

                    ListView listView = ItemsControl.ItemsControlFromItemContainer(lvItem) as ListView;

                    data.ContainingGrid = listView;
                    data.RowIndex       = listView.IndexFromContainer(lvItem);
                }
            }
        }