I am building a custom splitbutton that consists of two overlappi开发者_运维知识库ng buttons, and popup - like this (image shows some generic splitbutton):
SplitButton http://windowsclient.net/wf/blogs/jfoscoding/splitbutton.PNG
My SplitButton opens popup whan a right side with arrow is clicked, and executes SplitButton.Command when a main button is clicked.
In my case however sometimes the default action cannot execute, and in those cases, when a main button is clicked, I'd like to open the popup instead.
I have accomplished it, but the problem is this:
- the SplitButton is subclassed from ToggleButton
- in a ControlTemplate, I have a ToggleButton (the bottom one), and Button (shorter, overlaid on the top)
Button.Command="{TemplateBinding Command}"
(so I can do<SplitButton Command="{Binding MyDefaultAction}">...
)- problem: when a command cannot execute, the whole SplitButton gets disabled.
I'd like to keep having the same command, but to override the button's behavior so that it doesn't become disabled when Command.CanExecute() returns false. How can I do this?
Thank you!
Command is a dependency property and I'm pretty sure it is inherited by any control beneath it in the visual tree. So for the button you don't want disabled, set the command property to a different command or setting it to null may also work.
Alternatively,
Create your own dependency property...like this one
Dependency Propert
精彩评论