mo_al
mo_al

Reputation: 101

how to close WPF page like window

I want to close a WPF page but Close() for the page does not work. In a WPF window this.Close() closes the window but in a WPF page, it doesn't work.

Upvotes: 6

Views: 4526

Answers (2)

Kishore Kumar
Kishore Kumar

Reputation: 12864

replace the content of the container controller where you placed the page with some other or clear the container content

Upvotes: 0

Reed Copsey
Reed Copsey

Reputation: 564323

A page isn't a Window, and as such, it's not directly Closable. From the documentation for Page, a Page is intended to be "page of content that can be navigated to and hosted by" ...

You'll need to get a reference to the Page's host, and close it. If you're hosting this Page inside of a Window, you can close that Window.

Upvotes: 1

Related Questions