Quantcast
Channel: AvalonDock
Viewing all articles
Browse latest Browse all 2690

New Post: Deserialization, x:Name and Show/Hide panes

$
0
0

Hi,

I had trouble with this but I think you have to use the following:

 

 var window = dockManager.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == "windowContentId");

 

So as an example of showing and hiding from a menu item click:

 

private void WindowMenu_Click(object sender, RoutedEventArgs e)
        {
            var window = dockManager.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == "windowContentId");
            window.IsVisible = ((MenuItem)sender).IsChecked;
        }

 

Maybe a helper function(s) could be created to make this easier. Something like:

 

public LayoutAnchorable FindLayoutAnchorable(DockingManager dockManager, string contentId)
        {
            return dockManager.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == contentId);
        }

 

Or create a function in DockingManager.cs.

 

public LayoutAnchorable FindLayoutAnchorable(string contentId)
        {
            return this.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == contentId);
        }

 

So the example becomes:

 

private void WindowMenu_Click(object sender, RoutedEventArgs e)
        {
            FindLayoutAnchorable(dockManager, "windowContentId").IsVisible = ((MenuItem)sender).IsChecked;
        }

 

Or:

 

private void WindowMenu_Click(object sender, RoutedEventArgs e)
        {
            dockManager.FindLayoutAnchorable("windowContentId").IsVisible = ((MenuItem)sender).IsChecked;
        }

 

I might be barking up the wrong tree but this is how I have got round the problem.

 

Cheers

Richard


Viewing all articles
Browse latest Browse all 2690

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>