Cannot assign VisualStateGroup into property VisualStateGroups type must be assignable to ILISt

mc 4,596 Reputation points
2023-06-17T14:32:35.84+00:00

I am setting VisualState to Button

<Style TargetType="Button">

<Setter Property="VisualStateManager.VisualStateGroups">

<VisualStateGroup x:Name="CommonStates">

</VisualStateGroup>

</Setter>

</Style>

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
794 questions
{count} votes

Accepted answer
  1. Castorix31 85,806 Reputation points
    2023-06-18T13:57:19.7233333+00:00

    This test with a ControlTemplate I had copied from the doc works for me :

                   <ControlTemplate x:Key="RoundButton" TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="backgroundElement" 
                                Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                To="{TemplateBinding Background}"
                                Duration="0:0:0.3"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="backgroundElement" 
                                Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" 
                                To="Yellow" 
                                Duration="0:0:0.3"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Ellipse x:Name="backgroundElement" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding Foreground}" />
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </Grid>            
                </ControlTemplate>
    
    
    

    Then :

                <Button Template="{StaticResource RoundButton}" Width="100" Height=" 32" >Test Button</Button>
    

    Test :

    EllipseButton

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.