I am developing a Silverlight web part for Sharepoint 2010. I have a button in a datagrid as follows
<sdk:DataGridTemplateColumn Width="80" >
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="MarkBilledButton" Content="Mark Billed" VerticalAlignment="Center" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Click="MarkBilledButton_Click" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
private void MarkBilledButton_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
//string buttonContent = btn.Content.ToString();
MedwaiverTimeLog timeLogObj = btn.DataContext as MedwaiverTimeLog;
MedwaiverViewModel MedwaiverViewModelObj = new MedwaiverViewModel();
MedwaiverViewModelObj.ChangeBillingStatus(timeLogObj.ListItemId, "Billed");
btn.IsEnabled = false;
}
I want the make the button disable on button click which is happening on button click event. But when I click on that disable button it gets enabled. I don’t want to enable the button once it is disabled. How to do this? Can you please tell me where I am going wrong ? Or can you please provide me any code so that I can solve the above issue ?
I think you can achieve this by introducing binding of Button’s
IsEnableproperty to a boolean property in yourModelView. OnMarkBilledButton_Click, set that property toFALSE, and even if refresh happened of the control, due the internal WPF framework message pumping, or due the some programming (which is not visible here),IsEnableproperty of the button will be read fromModelView.Hope this helps.