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
95
Display year in UltraWeekView
posted

Hi

Our application contains an UltraWeekView on which we show tasks. Admittedly it is still a version 5.3 control, which is unlikely to be changed.

I have a request to be able to show the year alongside the date at the top of each day box. The date is currently being shown in the format "Thursday 28 May"

Is this possible using the built in functionality or am I going to have to go down the route of implementing IUIElementDrawFilter?

Thanks

Tom

Parents
No Data
Reply
  • 69832
    Suggested Answer
    Offline posted

    I like to use the IUIElementCreationFilter interface (as opposed to IUIElementDrawFilter) where possible sonce you are then less likely to have to reinvent any of the drawing code. The following example demonstrates how to solve the problem you describe here using that approach:

    using nsWeekView = Infragistics.Win.UltraWinSchedule.WeekView;

    this.ultraWeekView1.CreationFilter = new HeaderLongDateCreationFilter();

    #region HeaderLongDateCreationFilter
    public class HeaderLongDateCreationFilter : IUIElementCreationFilter
    {

        #region IUIElementCreationFilter Members

        void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent)
        {
            nsWeekView.DayNumberUIElement headerElement =
                parent as nsWeekView.DayNumberUIElement;

            if ( headerElement != null )
            {
                List<TextUIElement> textElements = new List<TextUIElement>();
                foreach(UIElement element in parent.ChildElements)
                {
                    if ( element is TextUIElement )
                        textElements.Add( element as TextUIElement );
                }

                if ( textElements.Count == 2 )
                    parent.ChildElements.Remove( textElements[1] );

                TextUIElement textElement = headerElement.GetDescendant( typeof(TextUIElement) ) as TextUIElement;
                if ( textElement != null )
                {
                    object dateContext = headerElement.GetContext( typeof(DateTime) );
                    if ( dateContext != null && dateContext is DateTime )
                    {
                        DateTime date = (DateTime)dateContext;
                        string dateText = date.ToLongDateString();
                        textElement.Text = dateText;
                        textElement.Rect = parent.RectInsideBorders;
                    }
                }
            }
        }

        bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent)
        {
            return false;
        }

        #endregion
    }
    #endregion HeaderLongDateCreationFilter

Children