I think Pentium10 wants to be able to specify via the constructor whether, at a later time, ShowDialog is allows to actually display a dialog. In other words, he really wants to be able to override ShowDialog, so that in his own ShowDialog he can check this magic permission variable and either bail, or call the base ShowDialog.
I'm not sure if this is technically correct, but it does seem to work. Pentium10, in your Window class, create another public method called ShowDialog that hides the inherited ShowDialog. Then inside, check your variable and only if it's allowed, call the base's ShowDialog method, like this:
public partial class Window3 : Window
{
bool _allowed { get; set; }
public Window3( bool allowed)
{
_allowed = allowed;
InitializeComponent();
}
public void ShowDialog()
{
if( !_allowed)
return;
else
base.ShowDialog();
}
}