首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与Catel的Raddocking以及如何避免初始化方法被召回

与Catel的Raddocking以及如何避免初始化方法被召回
EN

Stack Overflow用户
提问于 2015-05-22 22:12:23
回答 1查看 135关注 0票数 0

我知道,当我在raddocking的选项卡中有一个视图时,每次激活该视图时都会触发加载的事件。在我的旧代码中,我设置了一个IsFirstLoad布尔值属性来避免这种行为。在Catel中,我发现当视图模型/视图失去焦点时,视图模型本身就会关闭……这可不好!有什么办法可以避免这种情况吗?

谢谢

代码语言:javascript
复制
   04:04:18:328 => [DEBUG] [Catel.MVVM.ViewModelManager] [1] Unregistering all models of view model 'ServerMonitorViewModel' (id = '6')
04:04:18:329 => [DEBUG] [Catel.MVVM.ViewModelManager] [1] Unregistered all '0' models of view model 'ServerMonitorViewModel' (id = '6')
04:04:18:329 => [DEBUG] [Catel.MVVM.ViewModelCommandManager] [1] Unregistering commands on view model 'myApp..ServerMonitorViewModel' with unique identifier '6'
04:04:18:330 => [DEBUG] [Catel.MVVM.ViewModelCommandManager] [1] Unregistered commands on view model 'myApp..ServerMonitorViewModel' with unique identifier '6'
myApp.exe Information: 0 :     04:04:18:330 => [INFO] [Catel.MVVM.ViewModelBase] [1] Closed view model 'myApp..ServerMonitorViewModel'
04:04:18:331 => [DEBUG] [Catel.MVVM.ManagedViewModel] [1] Removed view model instance, currently containing '0' instances of type 'myApp..ServerMonitorViewModel'
04:04:18:335 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Initializing view model 'null'
04:04:18:335 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Uninitializing view model 'ServerMonitorViewModel'
04:04:18:335 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Uninitialized view model 'ServerMonitorViewModel'
04:04:18:336 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Initialized view model 'null'
04:04:18:355 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Uninitializing view model container to manage ViewToViewModel mappings
04:04:18:357 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Uninitialized view model container to manage ViewToViewModel mappings
04:04:25:346 => [DEBUG] [Catel.MVVM.Providers.LogicBase] [1] Target view 'ServerMonitorView' is loaded
04:04:25:348 => [DEBUG] [Catel.MVVM.Views.ViewManager] [1] Registering view 'IF.Tesoreria.Client.WPF.Views.ServerMonitorView'
04:04:25:349 => [DEBUG] [Catel.MVVM.Views.ViewManager] [1] Registered view 'IF.Tesoreria.Client.WPF.Views.ServerMonitorView'
04:04:25:352 => [DEBUG] [Catel.MVVM.Providers.UserControlLogic] [1] Searching for an instance of the InfoBarMessageControl
04:04:25:353 => [DEBUG] [Catel.MVVM.Providers.UserControlLogic] [1] Finished searching for an instance of the InfoBarMessageControl
04:04:25:354 => [DEBUG] [Catel.MVVM.Providers.UserControlLogic] [1] Found the parent view model container 'DockingPanesView' for 'ServerMonitorView'
04:04:25:354 => [DEBUG] [Catel.MVVM.Providers.UserControlLogic] [1] Subscribed to parent view model 'myApp..DockingPanesViewModel'
myApp.exe Information: 0 :     04:04:25:355 => [INFO] [Catel.MVVM.Providers.LogicBase] [1] DataContext of type 'myApp..ServerMonitorViewModel' is allowed to be reused by view 'IF.Tesoreria.Client.WPF.Views.ServerMonitorView', using the current DataContext as view model
04:04:25:375 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Initializing view model container to manage ViewToViewModel mappings
04:04:25:377 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Initializing view model 'ServerMonitorViewModel'
04:04:25:377 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Initialized view model 'ServerMonitorViewModel'
04:04:25:378 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Initialized view model container to manage ViewToViewModel mappings
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Telerik.Windows.Controls.RadListBox', AncestorLevel='1''. BindingExpression:Path=DataContext.Reconnect; DataItem=null; target element is 'EventToCommand' (HashCode=64707792); target property is 'Command' (type 'ICommand')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Telerik.Windows.Controls.RadListBox', AncestorLevel='1''. BindingExpression:Path=DataContext.Reconnect; DataItem=null; target element is 'EventToCommand' (HashCode=45499220); target property is 'Command' (type 'ICommand')
The thread 0x6a08 has exited with code 259 (0x103).
04:04:29:773 => [DEBUG] [Catel.MVVM.Providers.LogicBase] [1] Target control 'ServerMonitorView' is unloaded
04:04:29:775 => [DEBUG] [Catel.MVVM.Views.ViewManager] [1] Unregistering view 'IF.Tesoreria.Client.WPF.Views.ServerMonitorView'
04:04:29:776 => [DEBUG] [Catel.MVVM.Views.ViewManager] [1] Unregistered view 'IF.Tesoreria.Client.WPF.Views.ServerMonitorView'
04:04:29:777 => [DEBUG] [Catel.MVVM.Providers.UserControlLogic] [1] Cleared all warnings and errors caused by 'myApp..ServerMonitorViewModel (ID = 6)' since this is caused by a DataContext issue in the .NET Framework
04:04:29:779 => [DEBUG] [Catel.MVVM.Providers.UserControlLogic] [1] Unsubscribed from parent view model
04:04:29:785 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Initializing view model 'null'
04:04:29:786 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Uninitializing view model 'ServerMonitorViewModel'
04:04:29:788 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Uninitialized view model 'ServerMonitorViewModel'
04:04:29:788 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Initialized view model 'null'
04:04:29:792 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Uninitializing view model container to manage ViewToViewModel mappings
04:04:29:793 => [DEBUG] [Catel.MVVM.Views.ViewToViewModelMappingHelper] [1] Uninitialized view model container to manage ViewToViewModel mappings
EN

回答 1

Stack Overflow用户

发布于 2015-05-23 20:16:03

可以使用CloseViewModelOnUnloaded属性控制控件上视图模型的生存期。有关详细信息,请参阅the docs

请注意,在使用此功能时,您需要负责关闭视图模型。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30398999

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档