CloseViewModel doesn't close Window

Topics: Questions
Aug 19, 2013 at 1:00 PM

I got the problem, that 'm not able to close my view from the viewmodel.
It's my 2nd project where I'm using the catel framework..on the first project it worked fine, now I can't get it to work t close the view from the viewmodel. Can't really tell why, because I dont really see any major differences in my two projects. I created a complete clean catel wpf project iin visual studio and just placed a button on it:
<catel:DataWindow x:Class="WPFApplication1.Views.MainWindow"
                  ShowInTaskbar="True" ResizeMode="CanResize" SizeToContent="Manual" WindowStartupLocation="Manual" WindowState="Maximized">
    <!-- Resources -->
    <!-- Content -->
     <catel:StackGrid x:Name="LayoutRoot">
        <Button Content="Close" Command="{Binding CancelCommand}"/>
        public MainWindowViewModel()
            : base()
            CancelCommand = new Command(CancelMain);

        public Command CancelCommand { get; private set; }

        private void CancelMain()
..and it wont closes the view. I get following exception in the output:
01:48:16:526 => [DEBUG] [Catel.MVVM.ViewModelManager] Unregistering all models of view model 'MainWindowViewModel' (id = '1')
01:48:16:527 => [DEBUG] [Catel.MVVM.ViewModelManager] Unregistered all '0' models of view model 'MainWindowViewModel' (id = '1')
01:48:16:533 => [DEBUG] [Catel.Messaging.MessageMediator] Unregistered '0' handlers for the recipient with tag 'null'
01:48:16:545 => [DEBUG] [Catel.MVVM.ViewModelCommandManager] Unregistering commands on view model 'WPFApplication1.ViewModels.MainWindowViewModel' with unique identifier '1'
01:48:16:546 => [DEBUG] [Catel.MVVM.ViewModelCommandManager] Unregistered commands on view model 'WPFApplication1.ViewModels.MainWindowViewModel' with unique identifier '1'
01:48:16:548 => [DEBUG] [Catel.MVVM.ViewModelCommandManager] Disposing commands on view model 'WPFApplication1.ViewModels.MainWindowViewModel' with unique identifier '1'
01:48:16:549 => [DEBUG] [Catel.MVVM.ViewModelCommandManager] Disposed commands on view model 'WPFApplication1.ViewModels.MainWindowViewModel' with unique identifier '1'
"WPFApplication1.vshost.exe" (Verwaltet (v4.0.30319)): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.resources\v4.0_4.0.0.0_de_31bf3856ad364e35\PresentationFramework.resources.dll" geladen
A first chance exception of type "System.InvalidOperationException" accured in PresentationFramework.dll.
"WPFApplication1.vshost.exe" (Verwaltet (v4.0.30319)): "C:\Windows\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_de_b77a5c561934e089\mscorlib.resources.dll" geladen
A first chance exception of type "System.Reflection.TargetInvocationException" occured in mscorlib.dll.
WPFApplication1.vshost.exe Warning: 0 : 01:48:16:682 => [WARNING] [Catel.Windows.Controls.MVVMProviders.Logic.WindowLogic] Failed to set the 'DialogResult' property of window type 'MainWindow'
WPFApplication1.vshost.exe Information: 0 : 01:48:16:684 => [INFO] [Catel.MVVM.ViewModelBase] Closed view model 'WPFApplication1.ViewModels.MainWindowViewModel'
01:48:16:686 => [DEBUG] [Catel.MVVM.ManagedViewModel] Removed view model instance, currently containing '0' instances of type 'WPFApplication1.ViewModels.MainWindowViewModel'
Can someone tell me hat I'm dong wrong?
Aug 19, 2013 at 7:23 PM
Can you please upload your example here:
Aug 20, 2013 at 7:23 AM
Should I just created a new issue there with the issue type = task?
Wasn't sure, so I created a workitem here:

really no idea what I'm doing wrong =/. Worked in my prevous project but now even not on new project based on the catel template in visual studio.
Aug 20, 2013 at 7:24 AM
We no longer use the issue tracker of codeplex, so please create a task / issue / whatever you think is right. We will always review the new issues anyway.
Aug 20, 2013 at 7:35 AM
I see, sorry.

Task created here now:
Aug 24, 2013 at 7:40 PM
Just to close this discussioon, issue is solved in latest release.