Reputation: 339
Here's the problem:
I have a mainwindow with a frame where I load pages with a buttonpress, which I do like this:
private void btnKlanten_Click(object sender, RoutedEventArgs e)
{
frameMain.Source = new Uri("Frames/Klanten.xaml", UriKind.Relative);
}
On the pageview I made a custom close button, so when I click on it I simulate the page to be closed, what I actually do is set the visibility to collapsed:
private void Close_MouseDown(object sender, MouseButtonEventArgs e)
{
this.Visibility = Visibility.Collapsed;
}
Now the problem is that I can't find any way to make the page visible again. I tried insantiating the page on the window and accessing the visibility property that way, but that doesn't work.
The strange thing is that when I click on another button that loads another page in the frame, that does work. After I clicked on another button, when I click on the first button again, that shows again as well.
Is there any way to get this working?
Upvotes: 0
Views: 1296
Reputation: 45096
Just hold a reference to the page
private Page1 page1;
private void btnShowFrame(object sender, RoutedEventArgs e)
{
if (page1 == null)
{
page1 = new Page1();
frame1.Navigate(page1);
}
if (page1.Visibility != System.Windows.Visibility.Visible) page1.Visibility = System.Windows.Visibility.Visible;
}
Upvotes: 2