如何使avalon面板可见

时间:2017-06-05 02:20:59

标签: wpf panel visible avalondock

我有一个使用AvalonDock的WPF项目,问题是我想在点击 MenuItem 时显示关闭面板,我现在拥有如下:

<MenuItem Header="Views(_V)">
            <MenuItem Header="SolutionViews" IsCheckable="True" IsChecked="{Binding DocumentSolutionPanel.IsVisible, Mode=TwoWay}"/>
            <MenuItem Header="HardwareConfiguration" IsCheckable="True" IsChecked="{Binding DocumentHardwarePanel.IsVisible, Mode=TwoWay}"/>
            <MenuItem Header="HardwareInfo" IsCheckable="True" IsChecked="{Binding DocumentHWInfoPanel.IsVisible ,Mode=TwoWay}"/>
            <MenuItem Header="ConfigurationInfo" IsCheckable="True" IsChecked="{Binding DocumentConfigurationPanel.IsVisible, Mode=TwoWay}"/>
            <MenuItem Header="CommunicationParam" IsCheckable="True" IsChecked="{Binding DocumentCommunicationPanel.IsVisible, Mode=TwoWay}"/>
        </MenuItem>

以DocumentSolutionPanel为例:

public class DocumentSolutionPanelViewModel : AbstractPanelViewModel
{
    public DocumentSolutionPanelViewModel()
    {

    }
}

public abstract class AbstractPanelViewModel : AbstractViewModel
{
    private bool isVisible = false;

    public bool IsVisible
    {
        get { return isVisible; }
        set
        {
            if (isVisible == value)
                return;

            isVisible = value;
            OnPropertyChanged("IsVisible");
        }
    }

}

    private DocumentSolutionPanelViewModel _documentSolutionPanel = null;
    public DocumentSolutionPanelViewModel DocumentSolutionPanel
    {
        get
        {
            if (_documentSolutionPanel == null)
                _documentSolutionPanel = new DocumentSolutionPanelViewModel();

            return _documentSolutionPanel;
        }
    }

我的代码出了什么问题?谢谢!

0 个答案:

没有答案