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

Disable buttons after click

1 Answer 164 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
peter
Top achievements
Rank 1
peter asked on 10 May 2012, 02:11 PM
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;

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

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 15 May 2012, 11:43 AM
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 >>

Tags
Buttons
Asked by
peter
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or