I inherited a WPF app written by vendors in VS2017. In an attempt to upgrade it to VS2022, an error message is thrown:
The object ‘VisualStateGroup’ already has a child and cannot add
‘VisualState’. ‘VisualStateGroup’ can accept only one child.
This is the XAML that generates the error:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Normal" GeneratedDuration="0:0:0.3" To="MouseOver" />
<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.5" To="Normal" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver" />
<VisualState x:Name="Disabled" />
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected" />
<VisualState x:Name="SelectedUnfocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
Specifically the x:Name=”MouseOver”. Now I assume there is some tag missing to seperate the VisualState but for the life of me I cant figure it out. This code works fine in VS2019 thought.
Advise?