Posted 14 years ago
by SledgeHammer01
Version: 11.1.0543
Platform: .NET 4.0
Environment: Windows 7 (32-bit)
I have the following public properties in my VM:
public ObservableCollection<DocumentViewModelBase> Documents
{
get
{
if ((object)_lstDocuments == null)
_lstDocuments = new ObservableCollection<DocumentViewModelBase>();
return _lstDocuments;
}
}
public DocumentViewModelBase SelectedDocument
{
get
{
return _selectedVM;
}
set
{
if (_selectedVM != value)
{
_selectedVM = value;
OnPropertyChanged("SelectedDocument");
}
}
}
The documents property is bound like this:
<docking:DockSite local:DockSiteViewModelBehavior.IsManaged="True" themes:ThemeManager.Theme="{Binding ElementName=mainWindow, Path=(themes:ThemeManager.Theme)}"
DocumentItemsSource="{Binding Documents}" DocumentItemContainerStyle="{StaticResource DocumentItemStyle}">
The SelectedDocument property is bound like this:
<docking:Workspace Focusable="False" FocusVisualStyle="{x:Null}">
<docking:TabbedMdiHost Focusable="False">
<docking:TabbedMdiContainer SelectedValue="{Binding SelectedDocument}" />
</docking:TabbedMdiHost>
</docking:Workspace>
This all works properly. Document tabs are added properly, SelectedDocument is updated in the VM and updating it in the VM selects the tab as expected. SelectedDocument getter is called and returns the correct VM.
PROBLEM: I have a "logoff" command. The logoff command calls Documents.Clear() as one of its steps to logoff. When I call Documents.Clear(), it closes all the document windows as expected, but it seems like you lose the SelectedDocument binding. The getter is no longer called and SelectedDocuments no longer sets the active tab.
When I call Documents.Clear(), I see the following binding error:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ActiproSoftware.Windows.Controls.Docking.TabbedMdiContainer', AncestorLevel='1''. BindingExpression:Path=SelectedItem; DataItem=null; target element is 'DockingWindowTabPanel' (Name=''); target property is 'SelectedTab' (type 'UIElement')
If I call everything in my Logoff function EXCEPT Documents.Clear(), of course the tabs on the screen lose the content, but SelectedItem binding is not lost.
Also tried removing the VMs from Documents one by one and same problem with SelectedDocument binding getting lost.
public ObservableCollection<DocumentViewModelBase> Documents
{
get
{
if ((object)_lstDocuments == null)
_lstDocuments = new ObservableCollection<DocumentViewModelBase>();
return _lstDocuments;
}
}
public DocumentViewModelBase SelectedDocument
{
get
{
return _selectedVM;
}
set
{
if (_selectedVM != value)
{
_selectedVM = value;
OnPropertyChanged("SelectedDocument");
}
}
}
The documents property is bound like this:
<docking:DockSite local:DockSiteViewModelBehavior.IsManaged="True" themes:ThemeManager.Theme="{Binding ElementName=mainWindow, Path=(themes:ThemeManager.Theme)}"
DocumentItemsSource="{Binding Documents}" DocumentItemContainerStyle="{StaticResource DocumentItemStyle}">
The SelectedDocument property is bound like this:
<docking:Workspace Focusable="False" FocusVisualStyle="{x:Null}">
<docking:TabbedMdiHost Focusable="False">
<docking:TabbedMdiContainer SelectedValue="{Binding SelectedDocument}" />
</docking:TabbedMdiHost>
</docking:Workspace>
This all works properly. Document tabs are added properly, SelectedDocument is updated in the VM and updating it in the VM selects the tab as expected. SelectedDocument getter is called and returns the correct VM.
PROBLEM: I have a "logoff" command. The logoff command calls Documents.Clear() as one of its steps to logoff. When I call Documents.Clear(), it closes all the document windows as expected, but it seems like you lose the SelectedDocument binding. The getter is no longer called and SelectedDocuments no longer sets the active tab.
When I call Documents.Clear(), I see the following binding error:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='ActiproSoftware.Windows.Controls.Docking.TabbedMdiContainer', AncestorLevel='1''. BindingExpression:Path=SelectedItem; DataItem=null; target element is 'DockingWindowTabPanel' (Name=''); target property is 'SelectedTab' (type 'UIElement')
If I call everything in my Logoff function EXCEPT Documents.Clear(), of course the tabs on the screen lose the content, but SelectedItem binding is not lost.
Also tried removing the VMs from Documents one by one and same problem with SelectedDocument binding getting lost.