maui icon indicating copy to clipboard operation
maui copied to clipboard

[Windows] Crash on Windows, VisualStateGroup Names must be unique

Open jsuarezruiz opened this issue 7 months ago • 2 comments

Description

Have a Button Style using VisualStates and another Button using also VisualStates. Both, share the same VisualStateGroup name. Works on Android and iOS but crash on Windows.

Steps to Reproduce

  1. Download https://github.com/dotnet/maui/files/13873803/Test805RC1.zip
  2. Launch on Windows

Link to public reproduction project repository

https://github.com/dotnet/maui/files/13873803/Test805RC1.zip

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

jsuarezruiz avatar Jan 09 '24 13:01 jsuarezruiz

Could be related with https://github.com/dotnet/maui/pull/18680?

jsuarezruiz avatar Jan 09 '24 13:01 jsuarezruiz

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

ghost avatar Jan 11 '24 19:01 ghost

Verified this on Visual Studio Enterprise 17.9.0 Preview 5(8.0.3 & 7.0.101). Repro on Windows 11, not repro on Android 14.0-API34, iOS 17.2 and MacCatalyst with below Project: Test805RC1.zip

Windows: image

XamlTest avatar Feb 06 '24 08:02 XamlTest

Hi, I want to add some details to this bug that could be helpful.

Details:

Adding VisualStates to a button throws an exception "InvalidOperationException: VisualStateGroup Names must be unique". This problem can be replicated with only one User-defined VisualStateGroup in the project. This problem DOES NOT OCCUR when a button with specified VisualStates is created on a new page assigned to the new ShellContent in FlyoutItem structure in the AppShell.xaml file.

Reproduction steps:

  1. Create a new .NET MAUI project with the specified in the case version
  2. Replace the content of the MainPage.xaml file with the XAML code specified in the additional informations
  3. Delete content of the MainPage class leaving only its constructor and default content of it.
  4. Start debugging
  5. Observe thrown Exception

Version:

Installed Workload Id Manifest Version Installation Source

maui-windows 8.0.61/8.0.100 VS 17.10.35122.118

Reproduction:

5/5

additional informations:

XAML code that couse the exception (https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/button?view=net-maui-8.0#button-visual-states):

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiTest.MainPage">

    <VerticalStackLayout>
        <Button Text="Click me!">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal">
                        <VisualState.Setters>
                            <Setter Property="Scale"
    Value="1" />
                        </VisualState.Setters>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <VisualState.Setters>
                            <Setter Property="Scale"
    Value="0.8" />
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
        </Button>
    </VerticalStackLayout>

</ContentPage>

Structure of AppShell.xaml file on witch bug does not occur:

<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="MauiTest.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:MauiTest"
    Shell.FlyoutBehavior="Disabled"
    Title="MauiTest">
    <FlyoutItem>
        <ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="MainPage" />
        <ShellContent
        Title="NewPage"
        ContentTemplate="{DataTemplate local:NewPage1}"
        Route="MainPage" />
    </FlyoutItem>
</Shell>

SEGMK avatar Jul 26 '24 11:07 SEGMK