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
985
Set BackgroundColor to specific Dates
posted

Hi there

i have a list of datetime. Now, every day in the datetime-list should get a background color in the xamcalendar.

Could you please help me out here?

 

regards

Cloud 

  • 138253
    Verified Answer
    Offline posted

    Hello Cloud,

     

    Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I handled the CalendarDay’s Loaded event and in its handler I check if the List with the dates contains the loading day and if it does I changed its Background. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

    WpfApplication1.zip
    • 985
      posted in reply to Stefan

      thank you for the sample. that is almost what i need.

      some little point is just not the way i want. is it possible to set the event of the eventsetter to the event of another control? because in my project the event should be fired when my xamdatagrid activate a record. that would be awesome.

       ist it possible to do that somehow?

       

      regards

       

      Cloud 

      • 138253
        Offline posted in reply to Cloud Strife

        Hello Cloud,

         

        I have modified the sample I sent you before and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.

         

        Looking forward for your reply.

        WpfApplication2.zip
        • 985
          posted in reply to Stefan

           

          but one problem still exists.

          i´m using this xaml to set the color of my calendardays:

          <igEditors:XamMonthCalendar TodayButtonVisibility="Hidden" ShowDisabledDaysOfWeek="True" Name="mcMonthCalendar" Language="de-DE">
          <igEditors:XamMonthCalendar.Resources>
          <converter:DateToColor x:Name="dateConverter" x:Key="dateConverter"></converter:DateToColor>
          <Style TargetType="{x:Type igEditors:CalendarDay}">
          <Style.Triggers>
          <Trigger Property="IsEnabled" Value="False">
          <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource dateConverter}}"></Setter>
          </Trigger>
          </Style.Triggers>
          </Style>
          </igEditors:XamMonthCalendar.Resources>
          </igEditors:XamMonthCalendar>

           

          and my converter get as value a calendarday and returns the backgroundcolor for that special day.

          now i have this scenario:

          i set the range of the calendar with 2 datepicker. and when i press a button i set the min and maxdate of my monthcalendar.

          the first time i do this the colors where set correctly and all works fine.

          but when i now change the datepicker dates (e.g. mindate - 1month) then the colors are not in the right month but one month earlier.

           

          could you imagine why this happens?

          regards

          cloud

           

           

           

           

           

           

           

           

           

           

           

           

          <igEditors:XamMonthCalendar TodayButtonVisibility="Hidden" ShowDisabledDaysOfWeek="True" Name="mcMonthCalendar" Language="de-DE">
          <igEditors:XamMonthCalendar.Resources>
          <converter:DateToColor x:Name="dateConverter" x:Key="dateConverter"></converter:DateToColor>
          <Style TargetType="{x:Type igEditors:CalendarDay}">
          <Style.Triggers>
          <Trigger Property="IsEnabled" Value="False">
          <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource dateConverter}}"></Setter>
          </Trigger>
          </Style.Triggers>
          </Style>
          </igEditors:XamMonthCalendar.Resources>
          </igEditors:XamMonthCalendar>

          • 138253
            Offline posted in reply to Cloud Strife

            Hello Cloud,

            Since the DisabledDates Property is read only, it cannot be bound to a source, and you are not able to use a Converter. It seems that the approach I suggested you in my previous posts is the best one for achieving the functionality you want.

            • 985
              posted in reply to Stefan

               

              i still have one question:

              is it possible that every time my disableddates change, to give all this dates to a converter who sets me the borderbrush and the background of the calendardayitem?

              regards 

              Cloud

               

               

               

              • 138253
                Offline posted in reply to Cloud Strife

                Hello Cloud,

                 

                Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.

                 

                Thanks again.