During Silverlight ChildWindow closing animation user can click any button

有些话、适合烂在心里 提交于 2019-12-11 06:45:54

问题


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.

来源:https://stackoverflow.com/questions/12588642/during-silverlight-childwindow-closing-animation-user-can-click-any-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!