Hello,
I want to bind my Custom property to IsEnabled property of DataRecord of xamDataGrd.
Is there any way to do this? Can I do it using Style or something?
Thanks & Regards,
Abdi
Hello Abdeali,
You can create a style for DataRecordPresenter in the resources of XamDataGrid and by using a Setter you can bind it’s IsEnabled property to your custom property:
<Style TargetType="{x:Type igWPF:DataRecordPresenter}"> <Setter Property="IsEnabled" Value="{Binding Source={StaticResource vm},Path=Enabled}"/></Style>
I have attached simple project where you can see this approach.
Please let me know if you require any further assistance regarding this matter.
Sincerely, ZhivkoEntry Level Software Developer
Thanks for the reply. I am very close to the solution as per your suggestion. The only issue is I am unable to bind my property (from a collection) in DataTrigger:
<Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Setter Property="IsEnabled" Value="False"/> <Style.Triggers> <DataTrigger Binding="{Binding Record.DataItem.ReReversedTransactionID}" Value="{x:Null}" > <Setter Property="IsEnabled" Value="True"/> </DataTrigger>
</Style.Triggers>
</Style>
Here ReReversedTransactionID is the property i am trying to bind. The row should get enabled when value of this property is null. This style is under the xamDataGrid.Resources. This grid is bind with a DataSource and this property is present in this datasource.
Thanks,
You can try to specify the RelativeSource in the Binding that you are using and also change the expected value in the DataTrigger, for example:
<Style TargetType="{x:Type igWPF:DataRecordPresenter}"> <Setter Property="IsEnabled" Value="False"/> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.ReReversedTransactionID}" Value="null" > <Setter Property="IsEnabled" Value="True"/> </DataTrigger> </Style.Triggers></Style>
Hi Zhivko,
In my case Converter did the job!
Thanks for your inputs :)
I am glad your solution is working now.
Please let me know if you have any more questions.
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.ReverseTransactionID, Converter={StaticResource NumericToBoolConverterKey}}" Value="False" > <Setter Property="IsEnabled" Value="False"/> </DataTrigger>