示例#1
0
        internal void AddRecylableRow(DataGridRow row)
        {
            Debug.Assert(!_recyclableRows.Contains(row), "Expected row parameter to be non-recyclable.");

            row.DetachFromDataGrid(true);
            _recyclableRows.Push(row);
        }
        public void ClearDetailsContentInformationOnRecycle()
        {
            DataGrid dataGrid = new DataGrid();

            dataGrid.Height = 350;
            dataGrid.Width  = 350;
            this._isLoaded  = false;

            CustomerList customers = new CustomerList(20);

            dataGrid.ItemsSource = customers;
            dataGrid.Loaded     += this.dataGrid_Loaded;
            TestPanel.Children.Add(dataGrid);
            this.EnqueueConditional(delegate { return(this._isLoaded); });

            double scrollBarMax = 0;

            this.EnqueueYieldThread();
            EnqueueCallback(delegate
            {
                scrollBarMax                = dataGrid.VerticalScrollBar.Maximum;
                dataGrid.SelectedItem       = customers[0];
                dataGrid.RowDetailsTemplate = XamlReader.Load(@"
                    <DataTemplate  
                        xmlns:data=""clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data""
                        xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" 
                        xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
                        <Button Height=""50"" />
                    </DataTemplate>") as DataTemplate;
            });

            this.EnqueueYieldThread();
            EnqueueCallback(delegate
            {
                DataGridRow row = dataGrid.DisplayData.GetDisplayedElement(0) as DataGridRow;
                Assert.IsNotNull(row);
                double contentHeight = row.TestHook.DetailsPresenter.ContentHeight;
                Assert.AreNotEqual(0.0, contentHeight);

                // Unfortuantely, we cannot reliably get a row to be recycled through normal means but guarantee
                // that it will not be reused
                row.DetachFromDataGrid(true);
                contentHeight = row.TestHook.DetailsPresenter.ContentHeight;
                Assert.AreEqual(0.0, contentHeight);
            });

            EnqueueTestComplete();
        }