Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
210
ContentPane's AllowClose property does not work
posted

In my application we add programatically ContentPanes. If in the content pane we have an operation undergoing, we want to disable the close button of the ContentPane, until the operation undergoing finishes. For that we use AllowClose property. This works fine most of the time. But there are cases when we switch the value for AllowClose property from false to true quite fast. In those cases the close button remains disabled even though we have set the AllowClose to true. The close button becomes enabled only after we click on the content pane. Can you help me with this problem, or is this a limitation of the layout of the content pane control?

  • 69686
    Verified Answer
    posted

    Hello,

    The development team gave me some tips on what is going on in this scenario :

    This behavior is caused because the Close button is linked to a routed command. When a commandsource like a Button is associated with a command it hooks its CanExecute. In the case of routedcommands that means they are hooking the CommandManager-> RequerySuggested event. The WPF framework explicitly raises that event when you press the mouse button down or press a key which is why it “works” usually.

     What you can do to resolve this is to call the CommandManager->InvalidateRequerySuggested to have the commands requery the CanExecute state of the commands