Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Applying Style Trigger when using Unbound Fields on a XamDataGrid
posted

NetAdvantage WPF 9.2 XamDataGrid

Following KB010107 I can set a style trigger to highlight a row's bg color based on a value in the item's collection *as long* as there are no unbound fields. However, I'm using several unbound fields and the style trigger is never set. If I allow the grid to autogenerate the fields, the trigger works fine.

Question: How can I apply a style trigger when using unbound fields with a XamDataGrid? Preferably using pure XAML.

Sample XAML:

<Window.Resources>

  <Style TargetType="{x:Type igDP:DataRecordCellArea}">

      <Style.Triggers>

          <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, 

                                 Path=Record.DataItem.SomeProperty.IsOnline}" Value="True">

              <Setter Property="Background" Value="Green" />

          </DataTrigger>

      </Style.Triggers>

  </Style>

</Window.Resources>

 

 

 

<igDP:XamDataGrid x:Name="XamDataGrid1"

                  DataSource="{Binding Path=MyCollection.Items}">

 

    <igDP:XamDataGrid.FieldLayouts>

        <igDP:FieldLayout Key="MyKey">

 

            <igDP:FieldLayout.FieldSettings>

                <igDP:FieldSettings 

                CellClickAction="SelectRecord"

                AutoSizeOptions="DataCells" AllowRecordFiltering="False" />

            </igDP:FieldLayout.FieldSettings>

 

 

            <igDP:FieldLayout.Fields>

 

                <igDP:UnboundField

                    Name="EmployeeID"

                    Label="EmployeeID" 

                    BindingPath="EmployeeID" />

 

                <igDP:UnboundField

                    Name="IsOnline"

                    Label="IsOnline" 

                    BindingPath="SomeProperty.IsOnline" DataType="{x:Type sys:Boolean}" />

 

                <igDP:UnboundField Width="auto"

                    Name="Name" 

                    Label="Name" 

                    BindingPath="Name" BindingMode="TwoWay" />

 

            </igDP:FieldLayout.Fields>

 

        </igDP:FieldLayout>

    </igDP:XamDataGrid.FieldLayouts>

 

 

    <igDP:XamDataGrid.FieldLayoutSettings>

        <igDP:FieldLayoutSettings AutoGenerateFields="False" 

                              AllowAddNew="False" 

                              AllowDelete="False" 

                              AutoFitMode="ExtendLastField" 

                              AllowClipboardOperations="Copy" />

    </igDP:XamDataGrid.FieldLayoutSettings>

</igDP:XamDataGrid>