Skip to main content

Microsoft Silverlight

Answered Question Navigating from a frame to another frame using code-behindRSS Feed

(0)

johngumboc
johngumboc

Member

Member

0 points

1 Posts

Navigating from a frame to another frame using code-behind

Does anybody know how to duplicate this in code?

<HyperlinkButton NavigateUri="/ComingSoon" Content="Page Name" Style="{StaticResource PageHyperlinkButtonStyle}" TargetName="ContentFrame" />

 

I am navigating from a second frame(which contains a sub menu) to a (content frame).  The XAML works perfect, but I need to loan a XAP file first and then Navigate to the "ContentFrame".

So I need to Navigate after the code below which is in another XAML Page, so the FrameName.Navigate (new Uri("Page.xaml",UriKind.Relative)) method doesn't work because "FrameName" is not in the same page.

 Private void Button_Click(object sender, System.Windows.RoutedEventArgs e)

{

WebClient c =
new WebClient(); c.OpenReadCompleted += new OpenReadCompletedEventHandler(c_OpenReadCompleted); c.OpenReadAsync(new Uri("AnotherAssembly.xap", UriKind.Relative));
c.OpenReadCompleted += new OpenReadCompletedEventHandler(c_OpenReadCompleted);

 

 

 

K2P2
K2P2

Participant

Participant

1028 points

337 Posts

Re: Navigating from a frame to another frame using code-behind

Just a wild shot - can you send a local message to whoever has access to FrameName? 

LocalMessageSender localMessageSender = new LocalMessageSender ( "FrameListener" );
localMessageSender .SendAsync ( "NavigateTo,Page.xaml");
 

LocalMessageReceiver LMR = new LocalMessageReceiver ( "FrameListener");
LMR3.MessageReceived +=
new EventHandler<MessageReceivedEventArgs>( FrameListener_LocalMessageReceived );
LMR3.Listen ();

void FrameListener_LocalMessageReceived ( object sender, MessageReceivedEventArgs e)
{
   ParseNavRequest( e.Message );
}

Min-Hong Tang - MSFT
Min-Hong...

Contributor

Contributor

3375 points

377 Posts

Answered Question

Re: Navigating from a frame to another frame using code-behind

Hi

   If you are saying you can not find content frame in your childFrams's button click event.

   ((MainPage)App.Current.RootVisual).contentFrame will do the trick.

  If you are have problems while download xap on demand , i recommand you to watch this video.

   http://silverlight.net/learn/learnvideo.aspx?video=65687

  It's only 20 minutes , and will guide you to establish a download on demand application from ground up.

Best Regards

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities