I have a TabbedMdiContainer with several DocumentWindows. I want to be able to "hide" one of the windows (and therefore its corresponding Tab). I first tried binding the Visibility property of the DocumentWindow and it caused the document window to hide but the tab was still there. Then I saw some documentation indicating we should never set the Visiblity property of a DocumentWindow and instead use the IsOpen property. When I do that, however, the tab/window never displays.
Here is very trivial example:
<Window xmlns:editors="http://schemas.actiprosoftware.com/winfx/xaml/editors" xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking" x:Class="UpgradeTesting.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:UpgradeTesting"
mc:Ignorable="d"
Title="Actipro Upgrade Testing" Height="200" Width="400">
<Window.Resources>
<ResourceDictionary>
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
<Label Content="Show Tab 1?"/>
<CheckBox IsChecked="{Binding IsVisible, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/>
</StackPanel>
<docking:DockSite Grid.Row="1" Grid.Column="0" CanDocumentWindowsFloat="True">
<docking:Workspace>
<docking:TabbedMdiHost>
<docking:TabbedMdiContainer>
<docking:DocumentWindow Title="Tab One" IsOpen="{Binding IsTabOpen}">
<Label Content="Here is the content for Tab #1"/>
</docking:DocumentWindow>
<docking:DocumentWindow Title="Tab Two">
<Label Content="Here is the content for Tab #2"/>
</docking:DocumentWindow>
</docking:TabbedMdiContainer>
</docking:TabbedMdiHost>
</docking:Workspace>
</docking:DockSite>
</Grid>
</Window>
And the view model is:
public class MainViewModel : INotifyPropertyChanged
{
private bool _isVisible = true;
private bool _isTabOpen = true;
public event PropertyChangedEventHandler PropertyChanged;
public bool IsVisible
{
get { return _isVisible; }
set
{
_isVisible = value;
PropertyChanged(this, new PropertyChangedEventArgs("IsVisible"));
IsTabOpen = value;
}
}
public bool IsTabOpen
{
get { return _isTabOpen; }
set
{
_isTabOpen = value;
PropertyChanged(this, new PropertyChangedEventArgs("IsTabOpen"));
}
}
}
[Modified 5 years ago]