Question: In C I could write a plugin by having a shared library implement the following interface:

```
extern "C" int initialize(SomeArgument * state);
extern "C" int shutdown(SomeArgument * state);

```

Obviously this is a *very* high level interface, but I think it gets the point across. I've heard that a good use of reflection is to write plugins, but why would that be superior to what I have here? Using an interface like this gives the following advantages:

* faster (reflection isn't fast, both looking up methods and calling indirectly)
* memory (reflection has memory overhead)
* straight-forward (entry/exit points for the plugin are intuitively obvious)

Am I just missing something?

Answer: 
The `DataGrid` is virtualizing the items, the respective rows (i.e. containers) are only created when the row is in view.

You could either [turn off virtualization](http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingstackpanel.isvirtualizing.aspx) (which makes the first time loading very slow if you have many items, also the memory usage will be higher) or you just iterate over the data and check the values of the data objects' properties which should be bound to the data-grid. Usually you should not need the UI elements at all...
In my case `grid.UpdateLayout();` didn't help an I needed a `DoEvents()` instead:

```
    DataGridRow row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);

    if (row == null)
    {

        WPFTools.DoEvents();

        grid.ScrollIntoView(grid.Items[index]);
        row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
    }

    /// <summary>
    /// WPF DoEvents
    /// Source: https://stackoverflow.com/a/11899439/1574221
    /// </summary>
    public static void DoEvents()
    {
        var frame = new DispatcherFrame();

        Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
            new DispatcherOperationCallback(
                delegate (object f)
                {
                    ((DispatcherFrame)f).Continue = false;
                    return null;
                }), frame);

        Dispatcher.PushFrame(frame);
    }

```