Navigate in Frame from code
-
Hi, How can i navigate to another page in a frame from code behind. ex: I have a navigate frame, when i click on a link button from outside navigate frame i need to navigate it to another page by writing code behind. i try .. ContentFrame.UriMapper.MapUri(new Uri(@"/EmployeeList.xaml")); ContentFrame.Source = new Uri("/EmployeeList.xaml"); in the click event. error i get is Microsoft JScript runtime error: Unhandled Error in Silverlight Application Invalid URI: The format of the URI could not be determined. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at System.Uri..ctor(String uriString) at HRMS.MainPage.Menu_MenuItemClicked(Object sender, EventArgs e) at SilverlightMenu.Library.Menu.gridLevel2_MouseLeftButtonUp(Object sender, MouseButtonEventArgs e) at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName) Thankyou, YPKI
-
Hi, How can i navigate to another page in a frame from code behind. ex: I have a navigate frame, when i click on a link button from outside navigate frame i need to navigate it to another page by writing code behind. i try .. ContentFrame.UriMapper.MapUri(new Uri(@"/EmployeeList.xaml")); ContentFrame.Source = new Uri("/EmployeeList.xaml"); in the click event. error i get is Microsoft JScript runtime error: Unhandled Error in Silverlight Application Invalid URI: The format of the URI could not be determined. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at System.Uri..ctor(String uriString) at HRMS.MainPage.Menu_MenuItemClicked(Object sender, EventArgs e) at SilverlightMenu.Library.Menu.gridLevel2_MouseLeftButtonUp(Object sender, MouseButtonEventArgs e) at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName) Thankyou, YPKI
I have a static method that I call from any forms code behind. The default frame is the main navigation frame but I can pass in a frame if required
public static void NavigateTo(string sViewName)
{
//Get the content frame from the main page via the application
Frame oFR = (Application.Current.RootVisual as FrameworkElement).FindName("MainContent") as Frame;
NavigateTo(oFR,sViewName);
}public static void NavigateTo(Frame oFR, string sViewName)
{
if(!sViewName.StartsWith("/"))
{sViewName = string.Format("/{0}",sViewName);}
oFR.Navigate(new Uri(sViewName, UriKind.Relative));
}And call it passing in the name of the view. The view is in the app.xaml of course. Do some research into Silverlight navigation projects.
gUI.NavigateTo(sURL);
Never underestimate the power of human stupidity RAH