SilverLight 4 - How to have Buttons to switch between view in grid
I‘m trying to create a page with Silver Light 4, that is similar in functionality to the main page at the Silver Light Showcase website (h开发者_运维知识库ttp://www.silverlight.net/showcase/). Essentially I want to have buttons that change the view of the data in a Grid. One view might have just an image, another might have a smaller image with a smattering of data, and the third would be all the details.
I wondering if anyone has a recommendation of how to achieve this?I would place a Border control inside of the Grid. Then on button click change the border.Child to the new view. You could define each view in a seperate UserControl xaml file.
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border x:Name="contentFrame" />
<Button x:Name="changeViewButton" click="click_event" Grid.Row="1" Height="22" Width="150" />
</Grid>
// code behind
protected void click_event(object s, EventArgs e)
{
View1 view1 = new View1();
// add some code to decide which view to show, possible hold onto the view in memory etc.
this.ContentFrame.Child = view1;
}
精彩评论