I stumbled upon the problem of not being able to use a windows method as a property inside the objects initializer:
var window = new DialogWindow
{
DataContext = new YesNoDialogViewModel()
{
DialogMessage = confirmation.Content as string,
DialogTitle = confirmation.Title,
}
};
(window.DataContext as YesNoDialogViewModel).CloseWindowCommand = new ActionCommand(window.Close);
I wan't to do something like this:
var window = new DialogWindow
{
DataContext = new YesNoDialogViewModel()
{
DialogMessage = confirmation.Content as string,
DialogTitle = confirmation.Title,
CloseWindowCommand = new ActionCommand(window.Close)
}
};
However, i can't seem to figure it out (new ActionCommand(window.Close)
doesnt compile, cannot use window before its declared).
Is there any hack or workaround to just add the reference to the void anyways?