I recently got myself into Silverlight and I'm trying to develop an application where it reads data from XML.
My problem is that I have never understood how to actually navigate/make views visible/hidden/collapsed depending on what button the client is clicking. In example, this project reads the menu structure from a XML file and I'm using an ItemsControl to display the menuitems like this:
<ItemsControl ItemsSource="{Binding MenuItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Width="900" Height="40"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<Ite开发者_JAVA技巧msControl.ItemTemplate>
<DataTemplate>
<Button Tag="{Binding Url}" Content="{Binding Name}" Click="Button_Click"></Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
This code is in my MenuView.xaml (I'm using MVVM by the way) and on my MainPage.xaml I've included the MenuView like this:
<views:MenuView x:Name="menu" />
Now, when a user click one of the buttons, I need to show the correct view on my mainpage. The tricky thing (for me at least) is, that the content from the XML file is "of-type", so basically I have these views:
- TextPageView
- NewsPageView
Where the NewsPageView's layout is different than the TextPageView, which is just a regular textpage really.
How exactly should I be navigating/hiding/showing these views without using the navigation framework? :-)
Hope my question is clear, if not - please let me know and I will try to elaborate!
Thanks in advance.
All the best,
Bo
The Navigation Framework is your friend :)
精彩评论