GroupHeaderButton - Change Foreground to the button that is pressed

1 Answer 28 Views
ScheduleView
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Ohad asked on 20 Jul 2022, 06:53 AM

I want to change the Foreground of the button when pressed, I was able to do this for MouseOver but not for a pressed button

 

<Style TargetType="telerik:GroupHeaderButton">
    <Setter Property="helpers:ThemeHelper.CheckedBrush" Value="{StaticResource GridView_ItemBackground_Over}"/>
    <Setter Property="helpers:ThemeHelper.MouseOverBrush" Value="{StaticResource ItemBackground_MouseOver}"/>
    <Setter Property="helpers:ThemeHelper.PressedBrush" Value="{StaticResource GridView_ItemBackground_Over}"/>
    <Setter Property="Background" Value="{StaticResource AppointmentItemBackground_UnSelected}"/>
    <Setter Property="Foreground" Value="{StaticResource EditAppointmentTemplateBackGround}"/>
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Foreground" Value="{StaticResource ControlForeground_Normal}"/>
        </Trigger>
        <Trigger Property="IsPressed" Value="True">
            <Setter Property="Foreground" Value="{StaticResource ControlForeground_Normal}"/>
        </Trigger>
    </Style.Triggers>
</Style>

 

Although I registered Trigger to IsPressed but it does nothing

 

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 22 Jul 2022, 01:43 PM

Hello Ohad,

The style used for targeting the GroupHeaderButton element is one way of achieving the desired behavior. I have used it in a sample project and on my end when the element is pressed, the Foreground changes according to the set value in the Trigger.

The following snippet shows the RadScheduleView and the Style's implementation, which is present on my end, as well as the result:

<Grid>
    <Grid.Resources>
        <!--Sample view model as a resouce-->
        <local:MyViewModel x:Key="MyViewModel" />
        <!--GroupHeaderButton Style-->
        <Style TargetType="telerik:GroupHeaderButton">
            <Setter Property="Foreground" Value="Black"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Foreground" Value="red"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Foreground" Value="White"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Grid.Resources>
    <!--Sample RadScheduleView implementation-->
    <telerik:RadScheduleView DataContext="{StaticResource MyViewModel}" AppointmentsSource="{Binding Appointments}" >
        <telerik:RadScheduleView.ViewDefinitions>
            <telerik:DayViewDefinition/>
            <telerik:WeekViewDefinition/>
        </telerik:RadScheduleView.ViewDefinitions>
    </telerik:RadScheduleView>
</Grid>

The produced result when the element is pressed:

I have attached the test application, so, could you give it a try and let me know if I am missing something?

Regards,
Stenly
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Tags
ScheduleView
Asked by
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or