This is a migrated thread and some comments may be shown as answers.

Can I set the CommandParameter value via Element to Element binding?

1 Answer 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Don Cote
Top achievements
Rank 1
Don Cote asked on 18 Mar 2010, 09:41 PM
I have some checkboxes inside of a RadDropDownButton, which sits in an external theme that is applied to the RadScheduler control.  Everything is working properly and I'm able to hook up with the LeftClick event when I set a static string value for the CommandProperty, but I'm having trouble getting it to send over the IsChecked value from the checkbox.  Any ideas?
<CheckBox x:Name="CheckFilterDownline" IsChecked="True"
 
    <telerik:CommandManager.InputBindings> 
        <telerik:InputBindingCollection> 
            <telerik:MouseBinding Command="kenexa:AppointmentsViewModel.Filter"  
                                  CommandParameter="{Binding ElementName=CheckFilterDownline, Path=IsChecked}" Gesture="LeftClick" /> 
        </telerik:InputBindingCollection> 
    </telerik:CommandManager.InputBindings> 
 
</CheckBox> 

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 19 Mar 2010, 01:15 PM
Hello Don,

The InputBindings are more for providing command responses from UI elements that are not usually used for input, e.g. borders, rectangles, etc. For your case I would recommend creating an attached behavior that will receive the Command and CommandParameter properties and once set, will attach a handler on the Checked/Unchecked events, that will raise the command. The attached application demonstrates what I mean. However, it has one small problem - the CommandParameter binding is updated *after* the command is raised - this is because the IsChecked property is set when the Checked/Unchecked events are raised, which is the moment when the command is executed, but the binding is updated after the event handlers. Of course, for custom scenario like this you could hardcode the command parameter in the CommandCanExecuteChanged and ToggleButtonCheckedUnchecked methods to be always the value of the IsChecked property and everything should work as expected.

All the best,
Valeri Hristov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Don Cote
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or