Ejemplo n.º 1
0
        internal static void SetTriggerStyle(GridRow row, string propName)
        {
            if (row.DataGrid.RowTriggers.Count == 0)
            {
                return;
            }

            // Any trigger is activated
            RowTrigger matchTrigger    = null;
            bool       isTriggerActive = false;

            foreach (var trigger in row.DataGrid.RowTriggers)
            {
                if (propName == trigger.PropertyTrigger)
                {
                    matchTrigger = trigger;
                    if (trigger.CheckTriggerActivated(row.Context))
                    {
                        isTriggerActive = true;
                        break;
                    }
                }
            }

            if (matchTrigger == null)
            {
                return;
            }

            // No active trigger
            if (row.EnabledTrigger == null)
            {
                if (isTriggerActive)
                {
                    row.EnabledTrigger = matchTrigger;
                    row.UpdateStyle();
                }
            }
            // Has active trigger
            else
            {
                // Find other active trigger
                // Искать другие активные тригеры
                RowTrigger finalTrigger = null;
                for (int i = 0; i < row.DataGrid.RowTriggers.Count; i++)
                {
                    var t = row.DataGrid.RowTriggers[i];
                    if (t.CheckTriggerActivated(row.Context))
                    {
                        finalTrigger = t;
                        break;
                    }
                }

                row.EnabledTrigger = finalTrigger;
                row.UpdateStyle();
            }
        }
Ejemplo n.º 2
0
        internal static RowTrigger SetTriggerStyle(Row row, string propName, bool isNeedUpdate = true)
        {
            if (row.DataGrid.RowTriggers.Count == 0)
            {
                return(null);
            }

            // Any trigger is activated
            RowTrigger anyTrigger      = null;
            bool       isTriggerActive = false;

            foreach (var trigger in row.DataGrid.RowTriggers)
            {
                if (propName == trigger.PropertyTrigger)
                {
                    anyTrigger = trigger;
                    if (trigger.CheckTriggerActivated(row.BindingContext))
                    {
                        isTriggerActive = true;
                        if (!isNeedUpdate)
                        {
                            return(anyTrigger);
                        }
                    }
                    break;
                }
            }

            if (!isNeedUpdate)
            {
                return(null);
            }

            if (anyTrigger == null)
            {
                return(null);
            }

            if (anyTrigger != null && (row.enableTrigger == anyTrigger || row.enableTrigger == null))
            {
                if (isTriggerActive)
                {
                    row.enableTrigger = anyTrigger;
                    row.UpdateStyle();
                }
                else
                {
                    row.enableTrigger = GetFirstTrigger(row);
                    row.UpdateStyle();
                }
            }

            return(anyTrigger);
        }