DockingWindow.IsOpen not binding?

Docking/MDI for WPF Forum

Posted 8 years ago by Ben Johnson
Version: 13.1.0581
Platform: .NET 4.0
Environment: Windows 8 (64-bit)
Avatar

I'm using MVVM to add documents and tool windows to the docking & mdi framework and have all the properties I need working except the DockingWindow.IsOpen property binding. Is there a bug with binding to this property or maybe my code is incorrect?

 

View Bindings

<!-- docking:DockingWindow -->
<Style x:Key="DockingItemStyle" TargetType="docking:DockingWindow">
    <Setter Property="CanClose" Value="{Binding CanClose}"/>
    <Setter Property="CanMaximize" Value="{Binding CanMaximize}"/>
    <Setter Property="CanRaft" Value="{Binding CanRaft}"/>
    <Setter Property="Description" Value="{Binding Description}" />
    <Setter Property="HasTitleBar" Value="{Binding HasTitleBar}"/>
    <Setter Property="ImageSource" Value="{Binding ImageSource}" />
    <Setter Property="IsOpen" Value="{Binding IsOpen}"/>
    <Setter Property="IsSelected" Value="{Binding IsSelected}"/>
    <Setter Property="Title" Value="{Binding Title}"/>
    <Setter Property="CanDrag" Value="{Binding CanDrag}"/>
</Style>

 View Model

public abstract class DockingBase : INotifyPropertyChanged
    {
        private Boolean _CanClose = true;
        private Boolean _CanMaximize = true;
        private Boolean _CanRaft = true;
        private String _Description = String.Empty;
        private Boolean _HasTitleBar = true;
        private ImageSource _ImageSource;
        private Boolean _IsOpen = false;
        private Boolean _IsSelected = false;
        private String _Title = String.Empty;
        private Boolean _CanDrag = true;

        public DockingBase()
        {
            Id = Guid.NewGuid();
        }

        public Guid Id { get; protected set; }
        
        public Boolean CanDrag
        {
            get { return _CanDrag; }
            set
            {
                _CanDrag = value;
                NotifyPropertyChanged("CanDrag");
            }
        }
        
        public Boolean CanClose
        {
            get { return _CanClose; }
            set
            {
                _CanClose = value;
                NotifyPropertyChanged("CanClose");
            }
        }

        public Boolean CanMaximize
        {
            get { return _CanMaximize; }
            set
            {
                _CanMaximize = value;
                NotifyPropertyChanged("CanMaximize");
            }
        }

        public Boolean CanRaft
        {
            get { return _CanRaft; }
            set
            {
                _CanRaft = value;
                NotifyPropertyChanged("CanRaft");
            }
        }

        public String Description
        {
            get { return _Description; }
            set
            {
                _Description = value;
                NotifyPropertyChanged("Description");
            }
        }

        public Boolean HasTitleBar
        {
            get { return _HasTitleBar; }
            set
            {
                _HasTitleBar = value;
                NotifyPropertyChanged("HasTitleBar");
            }
        }

        public ImageSource ImageSource
        {
            get { return _ImageSource; }
            set
            {
                _ImageSource = value;
                NotifyPropertyChanged("ImageSource");
            }
        }

        public Boolean IsOpen
        {
            get { return _IsOpen; }
            set
            {
                _IsOpen = value;
                NotifyPropertyChanged("IsOpen");
            }
        }

        public Boolean IsSelected
        {
            get { return _IsSelected; }
            set
            {
                _IsSelected = value;
                NotifyPropertyChanged("IsSelected");
            }
        }

        public String Title
        {
            get { return _Title; }
            set
            {
                _Title = value;
                NotifyPropertyChanged("Title");
            }
        }

        protected void NotifyPropertyChanged(String property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }

Comments (4)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Ben,

DockingWindow.IsOpen is a dependency property that has a get/set.  I wonder if since we set the property as the DockingWindow opens/closes, that process of setting the local value removes the binding you set in the Style?


Actipro Software Support

Posted 8 years ago by Ben Johnson
Avatar

Ah.. That would cause my binding to be removed. Is there any way you guys could fix this in a next release?

Posted 8 years ago by Ben Johnson
Avatar

Using MVVM how do I make a panel/document that has been closed visible again? (seems that the Visibility property does not bind correctly either).

Answer - Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Ben,

We have to be able to set the property, but I believe customers have done this in the past.  What if you make the Binding a Mode=TwoWay?

<Setter Property="IsOpen" Value="{Binding IsOpen, Mode=TwoWay}" />

That should allow us to still set it and you to interact with it as well.


Actipro Software Support

The latest build of this product (v21.1.2) was released 15 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.