Disable buttons after click

2 posts, 0 answers
  1. peter
    peter avatar
    37 posts
    Member since:
    Feb 2011

    Posted 10 May 2012 Link to this post

    Hi i have 2 buttons which are in a radgridview. On click of either of the buttons i want both to be disabled. I am using MVVM so didnt want to do anything in the code behind, however if this is the only way then i will take it. The buttons already have a converter which disables or enables the buttons based on its value. This is what my code looks like so far;

     <StackPanel Orientation="Horizontal">
    <Telerik:RadButton  x:Name="_buttonApprove" IsEnabled="{Binding FormState,Mode=TwoWay,  Converter=StaticResource FormStateActionButtonConverter}}"  ToolTipService.ToolTip="Approve">
             <i:EventTrigger EventName="Click">
                 <cmd:EventToCommand Command="{Binding CanVerifyCommand, Source={StaticResource vm}}" CommandParameter="{Binding}"></cmd:EventToCommand>
    <Border Padding="7"></Border>
    <Telerik:RadButton x:Name="_buttonReject" IsEnabled="{Binding FormState,Mode=TwoWay,  Converter={StaticResource FormStateActionButtonConverter}}"  Tag="showrejectstaticdataformwindow"  ToolTipService.ToolTip="Reject">
             <i:EventTrigger EventName="Click">
                  <cmd:EventToCommand Command="{Binding ExecuteCommand, Source={StaticResource vm}}" CommandParameter="{Binding Tag, ElementName=_buttonReject}"></cmd:EventToCommand>

    Thanks in advance.
  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 15 May 2012 Link to this post

    Hi Peter,

    As you have bound both buttons' IsEnabled property to a property from your ViewModel, then the best approach would be to use the Commands you defined to change the value of this property so that it disables the buttons.

    It can be done easily in the CanVerifyCommand execution as it takes the business object as a command parameter. However, I am not sure what is your logic for the ExecuteCommand but you should be able to modify it so that it also changes the FormState property.

    I attached a sample project where clicking on the Approve button will disable both buttons in the GridView. Please let me know if this is close to what you have in mind or I'm missing something.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top