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
25
CellValuePresenter DataTrigger does not fire with 2 DataViews
posted

 Hi,

I have 2 DataViews looking at the same DataTable with RowFilters set on Both. The idea was to have one grid display a filtered version of the second (like a summary screen). What I wanted on top of that to use the CellValuePresenter to trigger when a certain cell has a certain value so I can change its cell color. I do this with a ValueConverter. It seems that only the first grid triggers on the value changing and thus I am only seeing the cell changing color on that grid and not the other.

Is there any way to make the DataTrigger fire on all grids bound to the same value on different DataViews?

 

...

 <Style TargetType="{x:Type igDP:CellValuePresenter}">
   <Style.Triggers>
      <DataTrigger Value="True">
         <DataTrigger.Binding>
            <Binding Converter="{StaticResource IsCellOver100Converter}" Path="DataItem.MyColumn" />
         </DataTrigger.Binding>
         <Setter Property="Background" Value="Green" />
        </DataTrigger>
     </Style.Triggers></Style>

...

<igDP:XamDataGrid  DataSoure={Binding DataView1}

...

<igDP:XamDataGrid  DataSource={Binding DataView2}

 

 Thanks

 

 

 

 

  • 25
    posted in reply to [Infragistics] Josh Smith

    I have sumitted the code to your support group, here is also the XAML and code to reproduce this issue....

    <Window x:Class="InfragisticsWithDataViewTest.Window1"
        xmlns="
    http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:igDP="http://infragistics.com/DataPresenter"
        xmlns:igEditors="http://infragistics.com/Editors"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:l="clr-namespace:InfragisticsWithDataViewTest"
        Title="Window1" Height="300" Width="300">
       
        <Window.Resources>
            <l:IsCellColoredConverter x:Key="IsCellColoredConverter" />

            <Style x:Key="NumericStyle" TargetType="{x:Type igEditors:XamNumericEditor}">
                <Setter Property="Format" Value="#,##0.00000" />
                <Setter Property="Mask" Value="{}{double:-9.5}" />
            </Style>
           
            <Style x:Key="ColoredCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
               <Style.Triggers>
                        <DataTrigger Value="True">
                      <DataTrigger.Binding>
                                <MultiBinding Converter="{StaticResource IsCellColoredConverter}" ConverterParameter="100">
                                    <Binding Path="DataItem.VALUE" />
                                    <Binding Path="DataItem" />
                                </MultiBinding>
                     </DataTrigger.Binding>
                            <Setter Property="Background" Value="#7732CD32" />
                        </DataTrigger>
                    </Style.Triggers>
                <Setter Property="Background" Value="#77FFE87C" />
            </Style>
        </Window.Resources>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <igDP:XamDataGrid Grid.Column="0" Grid.Row="0" Margin="4"
                              DataSource="{Binding Path=Grid1}" x:Name="_grid1" AutoFit="true" GroupByAreaLocation="None">
                <igDP:XamDataGrid.FieldSettings>
                    <igDP:FieldSettings AllowEdit="True" />
                </igDP:XamDataGrid.FieldSettings>
                <igDP:XamDataGrid.FieldLayouts>
                    <igDP:FieldLayout>
                        <igDP:FieldLayout.Fields>
                            <igDP:Field Name="VALUE" Label="Value" Visibility="Visible" >
                                <igDP:Field.Settings>
                                    <igDP:FieldSettings
                                        CellClickAction="EnterEditModeIfAllowed" EditorStyle="{StaticResource NumericStyle}"
                                        CellValuePresenterStyle="{StaticResource ColoredCellStyle}" />
                                </igDP:Field.Settings>
                            </igDP:Field>
                            <igDP:Field Name="DISPLAY" Visibility="Collapsed" />
                        </igDP:FieldLayout.Fields>
                    </igDP:FieldLayout>
                </igDP:XamDataGrid.FieldLayouts>
            </igDP:XamDataGrid>
          
            <igDP:XamDataGrid Grid.Column="1" Grid.Row="0" Margin="4"
                              DataSource="{Binding Path=Grid2}" x:Name="_grid2" AutoFit="true" GroupByAreaLocation="None">
                <igDP:XamDataGrid.FieldSettings>
                    <igDP:FieldSettings AllowEdit="True" />
                </igDP:XamDataGrid.FieldSettings>
                <igDP:XamDataGrid.FieldLayouts>
                    <igDP:FieldLayout>
                        <igDP:FieldLayout.Fields>
                            <igDP:Field Name="VALUE" Label="Value" Visibility="Visible" >
                                <igDP:Field.Settings>
                                    <igDP:FieldSettings CellClickAction="EnterEditModeIfAllowed" EditorStyle="{StaticResource NumericStyle}"
                                                        CellValuePresenterStyle="{StaticResource ColoredCellStyle}" />
                                </igDP:Field.Settings>
                            </igDP:Field>
                            <igDP:Field Name="DISPLAY" Label="Display" Visibility="Visible" />
                        </igDP:FieldLayout.Fields>
                    </igDP:FieldLayout>
                </igDP:XamDataGrid.FieldLayouts>
            </igDP:XamDataGrid>
        </Grid>
    </Window>

    ----- A simple bindable object is like so....

     public class ViewModel
        {
            private DataTable _table;

            public ViewModel()
            {
                _table = new DataTable();

                _table.Columns.Add("VALUE", typeof(double));
                _table.Columns.Add("DISPLAY", typeof(bool));

                _table.Rows.Add(10, true);
                _table.Rows.Add(20, true);
                _table.Rows.Add(30, true);
                _table.Rows.Add(40, true);
                _table.Rows.Add(200, true);
                _table.Rows.Add(300, true);
                _table.Rows.Add(400, false);
                _table.Rows.Add(500, false);
                _table.Rows.Add(600, false);
                _table.Rows.Add(40, false);
                _table.Rows.Add(30, false);
                _table.Rows.Add(20, false);
                _table.Rows.Add(10, false);

                Grid1 = new DataView(_table);
                Grid1.RowFilter = "[DISPLAY] = True";

                Grid2 = new DataView(_table);
            }

            public DataView Grid1 { get; set; }
            public DataView Grid2 { get; set; }
        }

    ---- And the converter is....

    public class IsCellColoredConverter : IValueConverter, IMultiValueConverter
        {
            public object Convert(object valueObj, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                if (valueObj is double)
                {
                    double value = (double)valueObj;

                    double threshold = 0;
                    double.TryParse(parameter.ToString(), out threshold);

                    return value >= threshold;
                }
                return false;
            }

            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }

            #endregion

            #region IMultiValueConverter Members

            public object Convert(object[ values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                return Convert(values[0], targetType, parameter, culture);
            }

            public object[ ConvertBack(object value, Type[ targetTypes, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }

  • 6867
    posted

    Hi,

    That doesn't sound right.  Please submit a small demo of this behavior to our Developer Support group and they can see that this issue gets the necessary attention/resolution.

    Thanks,

    Josh