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
1130
Set of EditorStyles
posted

Hi,

 I have a xamDataGrid, and for one particular cell I want to have one EditorStyle based on a boolean value from the data object being bound for that row.  Any ideas?

  • 3627
    posted

    You can absolutely do that. In fact, there's a lot of examples in this forum on how to achieve that using a style. Here is an example that I just posted for another question. It shows a boolean value being used to set the background color of a cell.

    <Window x:Class="XamDataGrid_Test_of_Dynamic_Style.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:local="XamDataGrid_Test_of_Dynamic_Style"
        Title="Window1" Height="300" Width="300">
        <Grid>
           
             <Grid.Resources>
                <Style x:Key="ManagerStyle" TargetType="{x:Type igDP:CellValuePresenter}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=(igDP:DataRecord.DataItem).IsManager}" Value="True">
                            <Setter Property="Background" Value="Red" />
                        </DataTrigger>
                    </Style.Triggers>
                   
                </Style>
            </Grid.Resources>

            <StackPanel Orientation="Vertical">

                <Button Name="ToggleManager" Click="ToggleManager_Click" Margin="20">Toggle Manager</Button>

                <igDP:XamDataGrid Name="TestGrid" AutoFit="True" GroupByAreaLocation="None">

                    <igDP:XamDataGrid.FieldLayouts>
                        <igDP:FieldLayout>

                            <igDP:FieldLayout.Fields>
                                <igDP:Field Name="Name">
                                    <igDP:Field.Settings>
                                        <igDP:FieldSettings CellValuePresenterStyle="{StaticResource ManagerStyle}" />
                                    </igDP:Field.Settings>
                                </igDP:Field>

                                <igDP:Field Name="IsManager" />
                            </igDP:FieldLayout.Fields>

                            <igDP:FieldLayout.SortedFields>
                                <igDP:FieldSortDescription FieldName="Name"
                                                       Direction="Ascending"
                                                       IsGroupBy="False" />
                            </igDP:FieldLayout.SortedFields>
                           
                        </igDP:FieldLayout>
                    </igDP:XamDataGrid.FieldLayouts>

                </igDP:XamDataGrid>

            </StackPanel>

        </Grid>
    </Window>