Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Bug] [Expander] InvalidOperationException: Header not initialized #1144

@kevin68

Description

@kevin68

Description

Since updating from XCT 1.0.3 to 1.1.0 the application throws an exception when displaying the main page that contains an Expander.
I found out that the crash happens when I set the property Direction to a value other than Down and whether or not I define a Header. After some digging it seems to come from this line which was added by this commit.

Exception: System.InvalidOperationException: Header not initialized.

Stacktrace (not much)
[mono] System.InvalidOperationException: Header not initialized
[mono]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.7(intptr,intptr,intptr)
[mono]   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.7(intptr,intptr,intptr)

Steps to Reproduce

  1. Create a blank Xamarin.Forms project
  2. Install the Xamarin Community Toolkit 1.1.0
  3. Add xmlns:xct="http://xamarin.com/schemas/2020/toolkit" to the main page
  4. Add a simple Expander with a Direction in the content of the main page
       <xct:Expander Direction="Right">
            <xct:Expander.Header>
                <Label Text="header"/>
            </xct:Expander.Header>
            <Label Text="content"/>
        </xct:Expander>
  1. Launch the app

Expected Behavior

The main page displays with the Expander

Actual Behavior

Visual studio catch an unhandled exception

Basic Information

  • Version with issue: 1.1.0
  • Last known good version: 1.0.3
  • IDE: Visual Studio 2019 16.9.2
  • Platform Target Frameworks:
    • iOS: 11.4
    • Android: 11.0
  • Android Support Library Version: None
  • Nuget Packages:
  • Affected Devices:
    • Pixel 3XL (Android 11.0)
    • Pixel 3a (Emulator, Android 9.0)
    • IPhone SE (iOS 14.4)

Workaround

Set the direction to Down, then change it after InitializeComponent() is called.

Reproduction imagery

N/A

Reproduction Link

Repro project (489ko)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions