public MainPage()
{
this.InitializeComponent();
// Make the Grid and set it to be the Page's .Content:
Grid grid = new Grid();
this.Content = grid;
// Make the GridView for the Grid, then set it:
GridView gridView = new GridView();
grid.Children.Add(gridView);
// Make the ItemsPanelTemplate; necessary?
ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate();
gridView.ItemsPanel = itemsPanelTemplate;
// Make the ItemsWrapGrid. Can't figure out how to set this.
ItemsWrapGrid itemsWrapGrid = new ItemsWrapGrid();
// When I traced the XAML version, its ItemsWrapGrid was apparently under
// gridView.ItemsPanelRoot
// , but that's a get-only property. I can't find a place to set it.
// Add the TextBlock's with "#1", "#2", and "#3":
for (int i = 1; i <= 3; ++i)
{
TextBlock textBlock = new TextBlock();
textBlock.Text = "#" + i.ToString();
gridView.Items.Add(textBlock);
}
// All done. However, this Grid will show contents with a vertical alignment
// rather than a horizontal one.
}

What additional code do I need to add to set the ItemsWrapGrid in C# as it was set in the XAML? Currently the C# code creates the ItemsWrapGrid, but the ItemsWrapGrid isn't actually set anywhere since every attempt to use it so far has resulted in a bug of some sort.

The fact is that the ItemsWrapGrid is the default panel for the GridView. It is not nice that the ItemsPanelTemplate cannot have the ItemsWrapGrid through a property and to use the XamlReader.
After the gridview is loaded it gets at ItemsPanelRoot a default ItemsWrapGrid.