Пример #1
0
        public void ShowIndicator(ValidatorBase validator)
        {
            try
            {
                //TODO: Refactor Indicator insertion to UserControl
                //There is an issue with adding the Indicator to the LayoutRoot and where it's positioned.
                //This way works for now, but should be refactored.

                //Modified by Reo, 需要显示到被验证控件的父元素
                //if (this.Parent == null)
                //{
                //    Panel g = (Panel)validator.UserControl.FindName("LayoutRoot");
                //    g.Children.Add(this);


                //    if (validator.ElementToValidate.Parent == g)
                //    {
                //        if (g is Grid)
                //        {
                //            var col = Grid.GetColumn(validator.ElementToValidate);
                //            var row = Grid.GetRow(validator.ElementToValidate);

                //            Grid.SetColumn(this, col);
                //            Grid.SetRow(this, row);
                //        }
                //        PositionIndicatorToRoot(validator);
                //    }
                //    else
                //    {
                //        PositionIndicator(validator);
                //    }
                //}

                //暂时不显示
                if (this.Parent == null)
                {
                    Panel g = (Panel)FindParentControl <Grid>(validator.ElementToValidate);
                    g.Children.Add(this);


                    if (validator.ElementToValidate.Parent == g)
                    {
                        if (g is Grid)
                        {
                            var col = Grid.GetColumn(validator.ElementToValidate);
                            var row = Grid.GetRow(validator.ElementToValidate);

                            Grid.SetColumn(this, col);
                            Grid.SetRow(this, row);
                            Grid.SetColumnSpan(this, Grid.GetColumnSpan(validator.ElementToValidate));
                            Grid.SetRowSpan(this, Grid.GetRowSpan(validator.ElementToValidate));
                        }
                        PositionIndicatorToRoot(validator);
                    }
                    else
                    {
                        PositionIndicator(validator);
                    }
                }

                if (!string.IsNullOrEmpty(validator.ErrorMessage))
                {
                    ToolTipService.SetToolTip(this, validator.ErrorMessage);
                }
                validator.UserControl.UpdateLayout();


                HideIndicatorStory.Stop();
                ShowIndicatorStory.Begin();
            }
            catch (Exception e) {
                var s = e;
            }
            // return;
        }
Пример #2
0
 public void HideIndicator()
 {
     ShowIndicatorStory.Stop();
     HideIndicatorStory.Begin();
 }