Category / Section
How to change the foreground for the Selected Time in SfTimePicker?
1 min read
To set the foreground for the selected time in SfTimePicker, SelectedForeground property can be set using the SelectorStyle of SfTimeSelector. The same has been demonstrated in the following code example:
XAML:
<Window x:Class="WpfApplication6.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:syncfusion="http://schemas.syncfusion.com/wpf" Title="MainWindow" Height="350" Width="525"> <Grid x:Name="Grid1"> <syncfusion:SfTimePicker VerticalAlignment="Center" Width="200" HorizontalAlignment="Center" > <syncfusion:SfTimePicker.SelectorStyle> <Style TargetType="syncfusion:SfTimeSelector"> <Setter Property="SelectedForeground" Value="Brown"/> </Style> </syncfusion:SfTimePicker.SelectorStyle> </syncfusion:SfTimePicker > </Grid> </Window>
C#:
namespace WpfApplication6 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); SfTimePicker TimePicker = new SfTimePicker(); TimePicker.VerticalAlignment = VerticalAlignment.Center; TimePicker.HorizontalAlignment = HorizontalAlignment.Center; TimePicker.Width = 200; Style style = new Style(typeof(SfTimeSelector)); style.Setters.Add(new Setter(SfTimeSelector.SelectedForegroundProperty, Brushes.Brown)); TimePicker.SelectorStyle = style; Grid1.Children.Add(TimePicker); } } }
Output: