Articles in this section
Category / Section

How to change background color for Looping Item in WPF DatePicker?

2 mins read

You can change the background color of selector items by using AlternativeBackground property of LoopingSelectorItem in WPF DatePicker (SfDatePicker). This property can be changed through the SelectorStyle property of SfDateSelector. The following code snippets demonstrate the same,

MainWindow.xaml

<Window.Resources>
  <Style TargetType="sfshared:LoopingSelectorItem" x:Key="ModifiedSelectorItemStyle" BasedOn="{StaticResource LoopingSelectorItemStyle}">
    <Setter Property="AlternativeBackground" Value="Black"/>
    <Setter Property="Foreground" Value="White"/>
  </Style>
  <Style TargetType="sfshared:LoopingSelector" x:Key="ModifiedSelectorStyle" BasedOn="{StaticResource LoopingSelectorStyle}">
    <Setter Property="ItemContainerStyle" Value="{StaticResource ModifiedSelectorItemStyle}"/>
  </Style>
</Window.Resources>
<Grid>
  <syncfusion:SfDatePicker Width="200" HorizontalAlignment="Center" VerticalAlignment="Center" AccentBrush="Gray">
    <syncfusion:SfDatePicker.SelectorStyle>
      <Style TargetType="syncfusion:SfDateSelector">
        <Setter Property="SelectorStyle" Value="{StaticResource ModifiedSelectorStyle}"/>
      </Style>
    </syncfusion:SfDatePicker.SelectorStyle>
  </syncfusion:SfDatePicker>
</Grid>

 

Changing Background of Selected Date in WPF SfDatePicker

View sample in GitHub.


Conclusion

I hope you enjoyed learning how to change the background color for LoopingSelectorItem in WPF DatePicker (SfDatePicker).

You can refer to our WPF DatePicker feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF DatePicker example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied