private void DynamoViewModelRequestShowHideGallery(bool showGallery)
{
if (showGallery)
{
if (galleryView == null) //On-demand instantiation
{
galleryView = new GalleryView(new GalleryViewModel(dynamoViewModel));
Grid.SetColumnSpan(galleryBackground, mainGrid.ColumnDefinitions.Count);
Grid.SetRowSpan(galleryBackground, mainGrid.RowDefinitions.Count);
}
if (galleryView.ViewModel.HasContents)
{
galleryBackground.Children.Add(galleryView);
galleryBackground.Visibility = Visibility.Visible;
galleryView.Focus(); //get keyboard focus
}
}
//hide gallery
else
{
if (galleryBackground != null)
{
if (galleryView != null && galleryBackground.Children.Contains(galleryView))
galleryBackground.Children.Remove(galleryView);
galleryBackground.Visibility = Visibility.Hidden;
}
}
}