开发者

Navigation framework in silverlight

开发者 https://www.devze.com 2023-03-10 19:14 出处:网络
In silverlight navigation framework how to navigate to a xaml page from mainpage.xaml ? In my scenario i havemenu items and need to go to correspondin开发者_开发百科g menu item\'s xaml page on menu cl

In silverlight navigation framework how to navigate to a xaml page from mainpage.xaml ? In my scenario i have menu items and need to go to correspondin开发者_开发百科g menu item's xaml page on menu click.


You can register a NavigationService variable on startup in your App.xaml.cs file. Assign the variable the first time you visit the page hosting the navigationframe - you get the NavigationService from the frame control.

In you menu usercontrol you can access the NavigationService in the App namespace: ((MyApp)App).NavigationService


Solution :- In xaml pages which are of type usercontrols the navigation can be carried out by adding navigation frames in xaml page.

Ex:- Xaml Page

<navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" 
                              Source="/Home" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed">
                <navigation:Frame.UriMapper>
                    <uriMapper:UriMapper>
                        <uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
                        <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
                    </uriMapper:UriMapper>
                </navigation:Frame.UriMapper>
            </navigation:Frame>

In .cs page

ContentFrame.Navigate(new Uri("URIPATH", UriKind.Relative));

// where URIPATH is the class to which the navigation is required

0

精彩评论

暂无评论...
验证码 换一张
取 消