HandyOrg / HandyControl

Contains some simple and commonly used WPF controls
https://handyorg.github.io/
MIT License
6.03k stars 1.02k forks source link

ToggleButton's Style.Triggers works only when ToggleButton's Style is set to "ToggleButtonCustom" #678

Open ms-somanna opened 3 years ago

ms-somanna commented 3 years ago

I'm trying to change the tooltip of a ToggleButton when ToggleButton is Checked/Unchecked using Style.Triggers as shown in code below.

<hc:ButtonGroup Margin="4,0,0,0" Orientation="Horizontal" Style="{StaticResource ButtonGroupSolid}" hc:BorderElement.CornerRadius="4" hc:BorderElement.Circular="True">
    <ToggleButton>
            <Path Data="{Binding Source={StaticResource PerspectiveViewCube}, Path=Data}"  Height="15" Width="15" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform" Fill="Gray" Stroke="{DynamicResource PrimaryTextBrush}"/>
                <ToggleButton.Style>
                    <Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource ToggleButtonBaseStyle}">
                            <Setter Property="ToolTip" Value="Turn ON Perspective View"/>
                                <Style.Triggers>
                                    <Trigger Property="IsChecked" Value="True">
                                            <Setter Property="ToolTip" Value="Turn OFF Perspective View"/>
                                        </Trigger>
                                </Style.Triggers>
                    </Style>
                </ToggleButton.Style>
        </ToggleButton>
</hc:ButtonGroup>

But its not working. The ToolTip is not displayed wether the ToggleButton is checked or unchecked. But if I set the style using BasedOn="{StaticResource ToggleButtonCustom}" it works. For any other Style it doesn't work.

ghost1372 commented 3 years ago

I did not look at the source code, but if it does not work, the tooltip not implemented