InvalidOperationException: VisualStateGroup Names must be unique
See original GitHub issueDescription
when i use VisualState, there are InvalidOperationException: VisualStateGroup Names must be unique at build time. like as:
<Entry FontSize="18">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Lime" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Focused">
<VisualState.Setters>
<Setter Property="FontSize" Value="36" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Pink" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Entry>
Steps to Reproduce
create a maui app add an entry add state group
Version with bug
6.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows
Affected platform versions
Android 10、windows sdk 10.0.19041.0
Did you find any workaround?
no workaround
Relevant log output
System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Exception has been thrown by the target of an invocation.
Source=Microsoft.Maui.Controls.Xaml
StackTrace:
at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.SetPropertyValue(Object xamlelement, XmlName propertyName, Object value, Object rootElement, INode node, HydrationContext context, IXmlLineInfo lineInfo)
at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.Visit(ElementNode node, INode parentNode)
at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
at Microsoft.Maui.Controls.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
at Microsoft.Maui.Controls.Xaml.XamlLoader.Visit(RootNode rootnode, HydrationContext visitorContext, Boolean useDesignProperties)
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Assembly rootAssembly, Boolean useDesignProperties)
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Boolean useDesignProperties)
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, Type callingType)
at Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml[TXaml](TXaml view, Type callingType)
at DataTrigger1.MainPage.InitializeComponent() in E:\z6\maui\learn1\DataTrigger1\DataTrigger1\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\MainPage.xaml.sg.cs:line 26
at DataTrigger1.MainPage..ctor() in E:\z6\maui\learn1\DataTrigger1\DataTrigger1\MainPage.xaml.cs:line 9
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
InvalidOperationException: VisualStateGroup Names must be unique
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Page crash when insert VisualState.Setters Property for " ...
Please include the exception in your title or edit post InvalidOperationException: VisualStateGroup Names must be unique it will be helpful ...
Read more >Simplifying Visual State Manager with TargetName
With the new TargetName property I am able to reference other elements by its name. Instead of having to repeat the whole visual...
Read more >VisualStateGroup Class (Windows.UI.Xaml) - UWP
Each name string used in the set of VisualStateGroups in a control template must be unique in that template. It's common to use...
Read more >Windows 10 Development: Table of Contents
developed multiple apps using the Microsoft Platform, our name is synonymous ... throw new InvalidOperationException("Frames must be either be registered.
Read more >sitemap2.xml
... https://www.telerik.com/forums/the-type-or-namespace-name-ganttprovider- ... .telerik.com/forums/new-quota-must-be-larger-than-the-old-quota-exception ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is all as it should. When not specifying the VisualGroupList explicitly, the XAML inflater will try to add to the existing one. The only difference with what you used to do in XF, is that a newly created app from template comes with a default style, including a style for entry.
that’s interesting… I had the impression the list was added implicitly. Will check