views:

56

answers:

1

hi,

is there any way i can write this code in a function() right now what is happening in function is
it tells e.Row.DetailsVisibility
e.DetailsElement.ActualHeight
it is not able to find this it is telling is there any way i can get this e.DetailsElement.ActualHeight

if (e.Row.DetailsVisibility == Visibility.Visible)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    DataGrid datagrid = sender as DataGrid;
                    if (datagrid != null)
                    {
                        datagrid.Tag = e.DetailsElement.ActualHeight;
                        datagrid.Height = datagrid.ActualHeight + e.DetailsElement.ActualHeight;
                    }
                }
                );
            }
            else
            {
                DataGrid datagrid = sender as DataGrid;
                if(datagrid.Tag!=null)
                    datagrid.Height = datagrid.ActualHeight - System.Convert.ToDouble(datagrid.Tag);

            }
        }
+1  A: 

Having in mind that you explanation is not very clear, what's the problem to put that code in a function as follows:

public void yourFunction(object sender, theTypeOfArguments e )
{
    if (e.Row.DetailsVisibility == Visibility.Visible)
    {
        Dispatcher.BeginInvoke(() =>
        {
            DataGrid datagrid = sender as DataGrid;
            if (datagrid != null)
            {
                datagrid.Tag = e.DetailsElement.ActualHeight;
                datagrid.Height = datagrid.ActualHeight + e.DetailsElement.ActualHeight;
            }
        }
        );
    }
    else
    {
        DataGrid datagrid = sender as DataGrid;
        if(datagrid.Tag!=null)
            datagrid.Height = datagrid.ActualHeight - System.Convert.ToDouble(datagrid.Tag);

    }
}

If that's not your question please give more clarifications.

Koynov