In a typical application, some content is used for navigation. In the case of Visual Studio, this can be represented by the Solution Explorer or Class View, enabling a person to jet off to the spot they are looking for. With this Infragistics
XamDockManager control, these types of panes exist within the DockManager.Panes collection, but not within the
DocumentContentHost. The one concern with navigation panes is that they are typically content-heavy with respect to either processing power or resource usage. To combat this, you’ll likely want not to destroy these panels each time you close them but, rather, simply hide them; to be made visible again at a later time.
Setting the CloseAction property of the
ContentPane to "HidePane" (Hide Pain?) partially helps you with this. The problem is that, using MVVM, there’s no way to change the visibility of the pane again to make it visible again. There is, however, a work-around. You can bind the visibility of the
ContentPane to a boolean property of your ViewModel, and raise the
INotifyPropertyChanged event every time you set the value, rather than trying to (more typically) not raise the value unless the property’s value has changed.
In the attached sample, I am combining some features of
PRISM (
DelegateCommands) with this to simplify the coding that is occuring. Here is some pseudo-code representing the relevant bits:
In MainWindowViewModel:
public
MainWindowViewModel() {
ShowNavigation =
new DelegateCommand<object>(x => NavigationVisible = true);
}
public DelegateCommand<object> ShowNavigation { get; set; }
public bool NavigationVisible {
get { return navigationVisible; }
set { navigationVisible = value; OnPropertyChanged("NavigationVisible"); }
}
In Window1:
<
MenuItem Header="_Control Panel" Command="{Binding ShowNavigation}"/>
<
igDock:ContentPane CloseAction="HidePane" Visibility="{Binding NavigationVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}">
<!– Content Here –>
</
igDock:ContentPane>
You can find the complete sample here:
Special thanks to Sam of Infragistics for helping me figure out that not declaring Mode=TwoWay makes for a lot of confusion.