Skip to main content

Microsoft Silverlight

Answered Question Navigating from a Page's child UserControlRSS Feed

(0)

WineNCheese
WineNCheese

Member

Member

3 points

3 Posts

Navigating from a Page's child UserControl

Hi, I've got a basic navigation scenario: 

My MainPage (UserControl) contains a navigation frame and uri mapper.

One of the pages that can be displayed in the frame contains a child UserControl, which contains a HyperlinkButton.

In this HyperlinkButton, I would like to utilize the UriMappings from the MainPage.  All attempts at doing this don't seem to work (setting or not setting the TargetName, etc). 

Any suggestions? 

I have no problems with HyperlinkButton's directly in the Page that contains the child UserControl.

Thanx

watabou
watabou

Member

Member

418 points

75 Posts

Answered Question

Re: Navigating from a Page's child UserControl

 I didn't knew navigation wasnt working on child window.

Whatever, you can do like this :

 
1. Create an EventHandler in Child Window
2. Fire the event once hyper link button is clicked in Child Window
3. In your Page.xaml hook up the submit event in Child Window
4. Do the navigation directly in your page

(If this has answered your question, please click on "mark as answer" on this post. Thank you!)
Hope it helps !
Bastien BESSON

WineNCheese
WineNCheese

Member

Member

3 points

3 Posts

Re: Re: Navigating from a Page's child UserControl

Thanx for the workaround thoughts.  I'd like to know if there is a way to do it that isn't a workaround.   And also, maybe an explanation why it doesn't work, if anybody's got that insight...

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

Contributor

Contributor

3375 points

377 Posts

Answered Question

Re: Re: Navigating from a Page's child UserControl

Hi,

   If you are saying you want to navigate in your child control's hyperlink button. Here is how i do it.

  ((MainPage)App.Current.RootVisual).ContentFrame.Navigate(new Uri(.....));  // add it in the hyperlinkButton's click event

  Based on my understand, because the hyperlinkButton is in a discrete namescrope with the Frame object. So that is why you can not just use it as noraml. Here is a link about xaml namescope.

 http://msdn.microsoft.com/en-us/library/cc189026(VS.95).aspx

 According to this document quote "templates define their own XAML namescopes". And frame has it's own template.

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