Skip to main content

Microsoft Silverlight

Answered Question SL3 Frame & Page controlsRSS Feed

(0)

CraigMuckleston
CraigMuc...

Member

Member

268 points

131 Posts

SL3 Frame & Page controls

I have a Frame control on my main page. I set the Frame's Content property to a Page control. When I am done with my Page, I want to close it and remove it (form within the Page events) from the Frames content. How can I do this?

AustinLamb
AustinLamb

Member

Member

602 points

104 Posts

Microsoft

Re: SL3 Frame & Page controls

You shouldn't set the Content property on Frame directly - if you do, most/all of the value Frame provides is lost :)  Instead, you should either set the Source property to a Uri of the Page to load, or use Frame.Navigate() to navigate to the page.

Beyond that, can you explain a bit more about what you're trying to achieve?  Frame/Page may not be the best solution, but without understanding the problem I don't have any other suggestions.

CraigMuckleston
CraigMuc...

Member

Member

268 points

131 Posts

Re: SL3 Frame & Page controls

Hi there,

I currently use the .Navigate event like this:

frmContent.Navigate(New Uri(goToPage, UriKind.Relative))

...and it loads fine. What I am trying to do is from the page that has just been loaded into the frame, I want to have say a Cancel button which will close the page. In other words, clear the forms source.

AustinLamb
AustinLamb

Member

Member

602 points

104 Posts

Microsoft
Answered Question

Re: SL3 Frame & Page controls

You could navigate the Frame somewhere else by calling NavigationService.Navigate(someOtherUri) from within the Page - that will navigate the Frame which is hosting the Page.  So you could navigate it to a home page or something to "reset" the Frame.

Another option could be to walk up the visual tree to find the Frame in the tree above the Page and set the Visibility of the Frame to make it "disappear".

But I'm still not sure I understand the scenario - why would a Page want to do this?  The problem would be that (for browser-integrated Frames) the user could still hit the back button in the browser and go back to the Page you're trying to "cancel" out of, which I am guessing you don't want based on your description.  If that's ok, then my above suggestions should work fine - but if that's not ok, then maybe Frame isn't really what you want to use in this case?

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities