I have a datagrid with one column as template column ,and I added a button to It . My xaml is :
<dg:DataGridTemplateColumn Header="Generate SlNo" Width="100">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="btnGenerateSlNO" Width="100" IsEnabled="{Binding IsSerialNoProduct,Mode=TwoWay}" Click="btnGenerateSlNO_Click">Generate SlNo</Button>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
My Data Class :
public class clsPurchaseBillEntryList : INotifyPropertyChanged, IDataErrorInfo
{
private bool _IsSerialNoProduct;
public bool IsSerialNoProduct
{
get { return _IsSerialNoProduct; }
set
{
_IsSerialNoProduct = value;
OnPropertyChanged("IsSerialNoProduct");
}
}
}
Now I want to enable and disable the button based on the Property IsSerialNoProduct.My problem is when the form is first load the button is showed as enabled .The property got value only when I click a cell in the datagrid because only my classes constructor is worked.I want to disable the button on form load how to accomplish this?