WPF add ScrollViewer to UniformGrid programatically

private static TabItem RenderSingleRow(String tabName, DataTable singleRow, int rowNumber)
{
try
{
var currentTabItem = new TabItem {Name = tabName, Header = tabName};

var scrollViewer = new ScrollViewer
{
CanContentScroll = true,
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto
};

var mainUniformGrid = new UniformGrid
{
Columns = 2,
VerticalAlignment = VerticalAlignment.Top,
Margin = UniformGridMargin
};

foreach (DataColumn singleRowColumn in singleRow.Columns)
{
StackPanel singleStackPanel = CreateSingleStackPanel(singleRowColumn.ColumnName,
singleRow.Rows[rowNumber][singleRowColumn].
ToString());
if (singleStackPanel != null) mainUniformGrid.Children.Add(singleStackPanel);
}

// CurrentTabItem.Content = MainUniformGrid;
scrollViewer.Content = mainUniformGrid;
currentTabItem.Content = scrollViewer;
return currentTabItem;
}
catch
{
return null;
}
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s