Calling a MessageBox from custom user control disables text boxes after returning.

9 views
Skip to first unread message

rama

unread,
Mar 26, 2009, 2:35:31 PM3/26/09
to WPF Graphics Site group
Hi,

I am current working on a WPF browser application. In brief, the
problem, I am seeing is that, the controls on a user control( ie
textboxes ) are disabled after returning from MessageBox.Show call.
Here is the description of what I am doing.

1) I have a main Page for the WPF browser application.
2) Defined an custom user control say MyUserControl
3) The user control is embeded in a Popup contol as follows in the
Page.xaml

<Popup Name="m_PopupMyUserControl" Placement="Center"
PlacementTarget="{Binding ElementName=Page}" StaysOpen="True">
<Border BorderBrush="Black" BorderThickness="1,1,1,1"
CornerRadius="1,1,1,1">
<local:MyUserControl x:Name="m_MyUserControl"
ButtonBase.Click="m_MyUserControl_Click" Background="White"></
local:MyUserControl>
</Border>
</Popup>

4) There is a button on the Page.xaml to show the Popup. The click
handler for the button is as follows:

void m_ButtonShowMyUserControl_Click( Object sender, RoutedEventArgs
e )
{
m_PopupMyUserControl.IsOpen = true;
IsEnabled = false;
}

4) The user control has few text boxes to get input and an "ok" and
"cancel" button.
5) In the processing of the "Ok" button, i validate the parameters
entered in the text boxes. If there is an error, then I call
MessageBox.Show method with the error message and mark the event as
handled. here is pseudo code for the buttonOk click event

void m_ButtonOk_Click( Object sender, RoutedEventArgs e )
{
if( !ValidateParameters() )
{
MessageBox.Show( "Error in input parameters" );
e.Handled = true;
}
}

The problem I am having is after I click "Ok" on the Message box, the
user control gets the focus, however, I cannot enter any text in the
text boxes as they seemed to have been disabled. I am not sure what
the problem may be. Also I am new to WPF, please let me know if
there is an obvious mistake I may be doing.

Thanks in advance.
Rama.
Reply all
Reply to author
Forward
0 new messages