I need help here. I'm trying to disable some rows edit on a WPF DataGrid. This is my XAML:
<DataGrid ItemsSource="{Binding Path=Combustibles}" AutoGenerateColumns="False" SelectedItem="{Binding Path=SelectedCombustible}">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsReadOnly}" Value="True" >
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
</DataGrid>
And this is my ViewModel:
public class CombustiblesViewModel: BaseViewModel
{
public List<CombustiblesWCFModel> Combustibles{ get; set; }
private CombustiblesWCFModel _selectedcombustible = new CombustiblesWCFModel();
public CombustiblesViewModel()
{
Combustibles = _svc.Combustibles_List(sTicket);
Combustibles[1].IsReadOnly = true;
}
public CombustiblesWCFModel SelectedCombustible
{
get
{
return this._selectedcombustible;
}
set
{
this._selectedcombustible = value;
NotifyOfPropertyChange("SelectedCombustible");
}
}
}
My Model has a Property:
public partial class CombustiblesWCFModel
{
public Boolean IsReadOnly { get; set; }
}
So, Row 1 should be disable for edditing or isn't?
My Finaly boal is to manually start row edit (With a link on each row) and confirm row edit with another link on each row to save data using a WCF services.