Question

O.K., taking a hint from my previous post, in short how do I get the trigger to fire on an attached property?

After more trial (and much error), I think I know where the problem is, but not how to fix it. When using drag and drop onto the datagrid, the Trigger responsible for changing the background of the DataGridCell only fires on the first drop or load into an unused cell. Outside of removing the data from the cell, in which case the cell returns to the color of the row, any further use of the cell returns its background to the first cell specific color it had and the trigger no longer fires.

                <DataGridTextColumn.ElementStyle>
                    <Style TargetType="TextBlock">
                        <Setter Property="Foreground" Value="Blue" />
                        <Style.Triggers>
                            <DataTrigger Value="True">
                                <DataTrigger.Binding>
                                    <MultiBinding Converter="{StaticResource watchNameConverter}" ConverterParameter="1">
                                        <Binding RelativeSource="{RelativeSource Self}" Path="Text"></Binding>
                                        <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}, AncestorLevel=1}"  Path="." />
                                        <Binding RelativeSource="{RelativeSource Self}" Path="."></Binding>
                                    </MultiBinding>
                                </DataTrigger.Binding>
                                <Setter Property="Background" Value="Purple"/>
                                <Setter Property="local:Scheduler.IsDirty" Value="True" />
                            </DataTrigger>

                            <Trigger Property="local:Scheduler.IsDirty" Value="true">
                                <Setter Property="Background">
                                    <Setter.Value>
                                        <MultiBinding Converter="{StaticResource colorTextConverter}" >
                                            <MultiBinding.Bindings>
                                                <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type DataGridCell}, AncestorLevel=1}"  Path="." />
                                            </MultiBinding.Bindings>
                                        </MultiBinding>
                                    </Setter.Value>
                                </Setter>

                            </Trigger>
                        </Style.Triggers>

                    </Style>
                </DataGridTextColumn.ElementStyle>
            </DataGridTextColumn>

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top