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

2 posts, 0 answers
  1. Don Cote
    Don Cote avatar
    11 posts
    Member since:
    Sep 2009

    Posted 18 Mar 2010 Link to this post

    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> 
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 19 Mar 2010 Link to this post

    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.
Back to Top