I would like to retrieve a list of links from SQLServer, and programmatically create some HyperlinkButtons from that list. These buttons should be added to a StackPnael. What is the best way to do this?
Something along the lines of:
private void RefreshMenu()
{
var dc = new FrameworkCMSDomainContext();
var query = dc.GetCMSPagesForSectionQuery(Section);
dc.Load(query, (s) =>
{
foreach(var page in dc.CMSPages)
{
HyperlinkButton btn = new HyperlinkButton();
btn.NavigateUri = new Uri("/" + Section + "/" + page.Name, UriKind.Relative);
btn.Content = page.Name;
btn.TargetName = "ContentFrame";
//Add to stackpanel here
}
}, null);
}
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel x:Name="LinksStackPanel" Orientation="Vertical">
</StackPanel>
<Button x:Name="AddPage" Click="AddPage_Click">Add</Button>
</Grid>