CellDecorator не обнаруживает программно выбранные ячейки - PullRequest
0 голосов
/ 26 октября 2018

Я использую Telerik RadCalendar, и когда я выбираю ячейки программно с помощью SelectDates, тогда CustomCellDecorator не обнаруживает его.

Я пишу следующий код в своем классе customRenderer в методе OnElementPropertyChanged. Код: -

 CellDecorator decorator = new FlagCellDecorator(Control);
    decorator.Color = 0;
    decorator.Stroked = true;
    decorator.Scale = 1.5f;
    Control.CellDecorator = decorator;
    Control.CellDecorationsLayer.StrokeWidth = 1f;
    Calendar calendar = Calendar.Instance;
    Control.SelectedDatesChanged += Control_SelectedDatesChanged;
    if (Element.AppointmentsSource != null && !IsSelected)
    {
      List<Long> dates = new List<Long>();
      foreach (var item in Element.AppointmentsSource)
      {
          calendar.Set(item.StartDate.Year, item.StartDate.Month, item.StartDate.Day);
          dates.Add(new Long(calendar.TimeInMillis));
          calendar.Set(item.EndDate.Year, item.EndDate.Month, item.EndDate.Day);
          dates.Add(new Long(calendar.TimeInMillis));
     }
     Control.SelectedDates = dates;
  }

Custom Cell Decorator Класс: -

class FlagCellDecorator : CellDecorator
    {
        private float offsetVertical;

        public FlagCellDecorator(RadCalendarView owner) : base(owner)
        {
            this.offsetVertical = owner.GridLinesLayer.Width / 2;
        }

        protected override void RenderDecorationForCell(Canvas canvas,
            CalendarCell cell)
        {

            int offsetHorizontal =
                (cell.Width - (int)(cell.Width * this.Scale)) / 2;


            canvas.DrawRoundRect(cell.VirtualLeft(),
                cell.VirtualTop(),
                cell.VirtualRight() - offsetHorizontal,
                cell.VirtualBottom(), 20, 20, this.Paint);
            canvas.DrawText(cell.Text,
                cell.TextPositionX() + cell.VirtualOffsetX,
                cell.TextPositionY() + cell.VirtualOffsetY,
                cell.TextPaint);
        }
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...