I am trying to do this:
<Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding DataItem.IsOnChart}" Value="true"> <Setter Property="Opacity" Value="1"/> </DataTrigger> <DataTrigger Binding="{Binding DataItem.IsOnChart}" Value="false"> <Setter Property="Opacity" Value="0.5"/> </DataTrigger> </Style.Triggers></Style>
From C#:
Style _DataRecordPresenterStyle = new Style(typeof(DataRecordPresenter));_DataRecordPresenterStyle.Setters.Add(new Setter(DataRecordPresenter.OpacityProperty, 1));var _DataTrigger = new DataTrigger() { Binding = new Binding("DataItem.IsOnChart"), Value = true };_DataTrigger.Setters.Add(new Setter(DataRecordPresenter.OpacityProperty, 1));_DataRecordPresenterStyle.Triggers.Add(_DataTrigger);_DataTrigger = new DataTrigger() { Binding = new Binding("DataItem.IsOnChart"), Value = false };_DataTrigger.Setters.Add(new Setter(DataRecordPresenter.OpacityProperty, 0.5));_DataRecordPresenterStyle.Triggers.Add(_DataTrigger);_Grid.FieldLayoutSettings.DataRecordPresenterStyle = _DataRecordPresenterStyle;
But when I bind the data to the grid I get the error:
Default Unhandled exception: Exception has been thrown by the target of an invocation.
What am I doing wrong here?
Thanks for your time.
Hello Scott,
I created a sample using your code and was unable to reproduce the error you are describing.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
Thank you,Mihoko Kamiishi
I would add that:
The data does have the field, it's type is a bool and the value is true on all records.