Hello,
Welcome to Microsoft Q&A!
>how can I set the visibility button when leaving or returning to a page or should I be doing something different
A common way is that you could override the Page.OnNavigatedTo Method and Page.OnNavigatedFrom Method.
Page.OnNavigatedTo Method is invoked when the Page is loaded and becomes the current source of a parent Frame.
Page.OnNavigatedFrom Method is invoked immediately after the Page is unloaded and is no longer the current source of a parent Frame.
In these methods, you could perform tasks such as initializing and saving the page state.
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.