Thursday, May 16, 2013

Identifying WPF BackStack Entries

Frame.BackStack is a useful property in WPF applications: it's an IEnumerable for a frame's navigation history. In my experience, these back entries tend to be JournalEntry instances. JournalEntry.Name can help you find what Page is represented by the JournalEntry, but it is a little tricky to use in practice. Name can be one of four things:
  1. The attached Name attribute.
  2. Title.
  3. WindowTitle and the uniform resource identifier (URI) for the current page
  4. The uniform resource identifier (URI) for the current page.
(Source: JournalEntry.Name documentation on MSDN)

If you set x:Name for a page, the corresponding JournalEntry.Name will be that x:Name. Doing this allows you to (somewhat) reliably identify the JournalEntry's page.

No comments:

Post a Comment