This project has moved and is read-only. For the latest updates, please go here.

DropDownButton/SplitButton unable to set IsOpen when IsEnabled="False"

Nov 9, 2011 at 4:17 PM

Hi all,

In the application I am currently working on, we wish to implement DropDownButtons and SplitButtons, an example implementation is:

<extendedToolkit:DropDownButton x:Name="NewDropDown">
			<MenuItem Command="{Binding Path=CreateNewAccommodationLineTypeCommand, Mode=OneTime}" Header="Accomodation" />
			<MenuItem Command="{Binding Path=CreateNewTransportLineTypeCommand, Mode=OneTime}" Header="Transport" />
			<MenuItem Command="{Binding Path=CreateNewOtherLineTypeCommand, Mode=OneTime}" Header="Other" />

However, each of our commands ends up setting the IsEnabled property of a parent of the DropDownButton to false. This in turns disables the DropDownButton, which all works as expected, however the PopUp remains open. I have attempted to remedy this with a style, defined as the following:

<Style TargetType="{x:Type extendedToolkit:DropDownButton}">
		<Trigger Property="IsEnabled" Value="False">
			<Setter Property="IsOpen" Value="False" />

I was expecting this to hide the popup when the IsEnabled becomes false, the trigger does get raised, however the setter does not work, it almost appears that it is impossible to set the IsOpen property to false, I have tried different setters, e.g.

<Setter Property="Content" Value="Disabled" />

And these work as expected.

Any help would be greatly appreciated.



Nov 15, 2011 at 1:52 PM

Is there no way to get this working? Or do you require a better example to demonstrate what I mean?



Nov 15, 2011 at 3:20 PM

Sorry, this post slipped through the cracks.  I didn't even know about it.  To accomplish your task I would suggest adding an IsOpen property to your VM and setting that to false before setting IsEnabled to false.

            <extToolkit:DropDownButton Content="Click Me" IsEnabled="{Binding IsEnabled}" IsOpen="{Binding IsOpen, Mode=TwoWay}" >
                        <Button Margin="10" Command="{Binding ClickCommand}" >OK</Button>
        //Command execute method
        private void Execute()
            IsOpen = false; //close the popup first
            IsEnabled = false; //now set to disabled
Nov 16, 2011 at 5:28 PM

That seemed to work, thanks for finding a solution :)