1

I am developing a rich user interface using Silverlight 5. I have lots of ChildWindows. Child Window has sort of buttons which are bound with Commands. I realized that if Child Window Close method is called, closing animation begins. However during animation user can click any button, which causes unexpected situations. To prevent this I need to unbind all buttons immediately on close request. I don't like to put this logic everywhere. Do you have any better solutions?

<Grid x:Name="LayoutRoot" DataContext="{StaticResource ResourceKey=viewModel}">
    <StackPanel>
        <TextBlock Text="{Binding ConfirmMessage}" HorizontalAlignment="Center" Margin="5"/>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Width="120" Height="30" Content="Yes" Margin="5" Command="{Binding ConfirmedCommand}"/>
            <Button Width="120" Height="30" Content="No" Margin="5" Command="{Binding RejectedCommand}"/>
        </StackPanel>
    </StackPanel>
</Grid>

To clarify, use a simple child window with above content. And bind ConfirmedCommand and RejectedCommand to simple commands which executes informative message boxes. Try close child window with close button on top right. During animation fastly click one of the buttons. You will see the message.

Edit: I have removed closing animation and it solved the problem in another way. For those who wants animation original problem remains same.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 1
    You can get past this by layering a UI component within the Grid that has a low opacity so it's not visually there but is _there_ which will stop the clicking of items underneath it. – Aaron McIver Sep 25 '12 at 18:09
  • This is a good idea. I think this solution must be done in component level. Doing this manually is still annoying. – Ahmed Yasin Koculu Sep 25 '12 at 18:18

0 Answers0