C# Avalondock MVVM-可见性

C# Avalondock MVVM-可见性,c#,wpf,mvvm,visibility,avalondock,C#,Wpf,Mvvm,Visibility,Avalondock,我可能还有一个简单的问题: 我正在尝试构建一个非常简单的MVVM应用程序: XAML: <StackPanel> <StackPanel.Resources> <ad:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/> </StackPanel.Resources> <ad:DockingManage

我可能还有一个简单的问题:

我正在尝试构建一个非常简单的MVVM应用程序:

XAML:

<StackPanel>
        <StackPanel.Resources>
            <ad:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        </StackPanel.Resources>
        <ad:DockingManager DocumentsSource="{Binding Path=Networks, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                           ActiveContent="{Binding Path=Active, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Height="300">
            <ad:LayoutRoot>
                <ad:LayoutPanel>
                    <ad:LayoutDocumentPane/>
                </ad:LayoutPanel>
            </ad:LayoutRoot>
            <ad:DockingManager.LayoutItemTemplate>
                <DataTemplate>
                    <TextBox Text="{Binding Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                </DataTemplate>
            </ad:DockingManager.LayoutItemTemplate>
            <ad:DockingManager.LayoutItemContainerStyle>
                <Style TargetType="{x:Type ad:LayoutItem}">
                    <Setter Property="Title" Value="{Binding Model.Title}"/>
                    <Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
                </Style>
            </ad:DockingManager.LayoutItemContainerStyle>
        </ad:DockingManager>
        <ListBox ItemsSource="{Binding Path=Networks, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                 SelectedItem="{Binding Path=Active, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <CheckBox IsChecked="{Binding Path=IsVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Content="{Binding Path=Title, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </StackPanel>
我想通过复选框将文档设置为可见或隐藏,但IsVisible属性不会更新

谢谢

编辑:

我发现如果我使用:

<ad:DockingManager DocumentsSource="{Binding Path=Networks, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                   AnchorablesSource="{Binding Path=Networks, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                   ActiveContent="{Binding Path=Active, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Height="300">

锚地的隐藏起了作用。 是否可能我无法隐藏文档(

public class DocumentVM : INotifyPropertyChanged
        {
            public DocumentVM(string Title, string Text)
            {
                this.Title = Title;
                this.Text = Text;
            }

            private const string IsVisiblePropertyName = "IsVisible";
            private bool _IsVisible;
            public bool IsVisible
            {
                get
                {
                    return _IsVisible;
                }
                set
                {
                    _IsVisible = value;
                    RaisePropertyChanged(IsVisiblePropertyName);
                }
            }

            private const string TitlePropertyName = "Title";
            private string _Title;
            public string Title
            {
                get
                {
                    return _Title;
                }
                set
                {
                    _Title = value;
                    RaisePropertyChanged(TitlePropertyName);
                }
            }

            private const string TextPropertyName = "Text";
            private string _Text;
            public string Text
            {
                get
                {
                    return _Text;
                }
                set
                {
                    _Text = value;
                    RaisePropertyChanged(TextPropertyName);
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;
            protected void RaisePropertyChanged(string name)
            {
                PropertyChangedEventHandler handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(name));
                }
            }
        }
<ad:DockingManager DocumentsSource="{Binding Path=Networks, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                   AnchorablesSource="{Binding Path=Networks, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                   ActiveContent="{Binding Path=Active, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Height="300">