Help needed!
Hi, I have a similar implementation and it works fine except that when showing and closing one dialog after another the second dialog doesn't respond anymore and only closes on clicking the x-Button with the result that the parent window remains disabled. Here's my implementation:
Hi, I have a similar implementation and it works fine except that when showing and closing one dialog after another the second dialog doesn't respond anymore and only closes on clicking the x-Button with the result that the parent window remains disabled. Here's my implementation:
public class ShowDialog : IResult
{
readonly Type screenType;
readonly Screen _screen;
readonly string name;
[Import]
public IWindowManager WindowManager { get; set; }
public ShowDialog( string name )
{
this.name = name;
}
public ShowDialog( Type screenType )
{
this.screenType = screenType;
}
public ShowDialog( Screen screen )
{
_screen = screen;
}
public void Execute( ActionExecutionContext context )
{
var screen = _screen != null ? _screen :
( !string.IsNullOrEmpty( name )
? IoC.Get<object>( name )
: IoC.GetInstance( screenType, null ) );
Dialog = screen;
WindowManager.ShowDialog( screen );
var deactivated = screen as IDeactivate;
if ( deactivated == null )
Completed( this, new ResultCompletionEventArgs() );
else
{
deactivated.Deactivated += ( o, e ) =>
{
if ( e.WasClosed )
{
Completed( this, new ResultCompletionEventArgs() );
}
};
}
}
public object Dialog { get; private set; }
public event EventHandler<ResultCompletionEventArgs> Completed = delegate { };
public static ShowDialog Of<T>()
{
return new ShowDialog( typeof( T ) );
}
public static ShowDialog Init( Screen screen )
{
return new ShowDialog( screen );
}
}
Thanks!