Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Grid-Based Sliding Panel Content Misalignment When Visibility Changes Programmatically #27434

Open
BrundhaVelusamy opened this issue Jan 29, 2025 · 2 comments
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter p/2 Work that is important, but is currently not scheduled for release partner/syncfusion Issues / PR's with Syncfusion collaboration platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@BrundhaVelusamy
Copy link

BrundhaVelusamy commented Jan 29, 2025

Description

When implementing a custom NavigationDrawer using a Grid in .NET MAUI, the content of the drawer layout visibility is set to false initially, and then programmatically changed to true, causing content misalignment issues. Specifically:

  • The controls inside the DrawerContent do not render properly or remain invisible.
  • On runtime, updating the width, height, or any other properties of the affected controls after setting visibility to true makes them visible.

This behavior suggests a potential layout invalidation issue when toggling visibility programmatically.

Sample: DrawerCustomSample.zip

Video: Demo

Steps to Reproduce

  1. Run the sample mentioned in the description.
  2. Click the 'ToggleDrawer' button. The drawer will open with no content, as the visibility of the content is set as false initially.
  3. Again click the 'ToggleDrawer' button. The drawer will close.
  4. Click the "ChangeVisibility" button to programmatically set the DrawerContent visibility to true.
  5. Again click the 'ToggleDrawer' button. The drawer will open.
  6. Observe that the controls inside the sliding panel are either misaligned or not visible.
  7. Manually update any layout property (e.g., WidthRequest or HeightRequest) to force a refresh, which makes the controls render correctly.

Link to public reproduction project repository

No response

Version with bug

9.0.30 SR3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

No response

Affected platforms

iOS, macOS

Affected platform versions

No response

Did you find any workaround?

If the DrawerContent's visibility is set to true while the drawer is open, the controls align and render correctly.

SlingPanel_Workaround.mp4
@BrundhaVelusamy BrundhaVelusamy added the t/bug Something isn't working label Jan 29, 2025
@vishnumenon2684 vishnumenon2684 self-assigned this Jan 29, 2025
@vishnumenon2684 vishnumenon2684 added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 29, 2025
@tj-devel709 tj-devel709 added platform/macOS 🍏 macOS / Mac Catalyst area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/iOS 🍎 p/2 Work that is important, but is currently not scheduled for release labels Jan 29, 2025
@tj-devel709 tj-devel709 added this to the .NET 9 Servicing milestone Jan 29, 2025
@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Feb 5, 2025
@Marnie-Majait
Copy link

This issue has been verified Visual Studio Code 1.96.4 (9.0.30 & 9.0.22 & 9.0.0). Can repro this issue on iOS and macOS platform.

@KarthikRajaKalaimani
Copy link
Contributor

KarthikRajaKalaimani commented Feb 13, 2025

Hi @BrundhaVelusamy ,

The VerticalStackLayout requires an additional layout pass. As a workaround to ensure proper rendering, please call the InvalidateMeasure method of the VerticalStackLayout after the visibility of the DrawerContent changes from false to true.

private void UpdateDrawerPosition()
{
var drawerTranslation = _isDrawerOpen ? 0 : -250;
DrawerContent.TranslateTo(drawerTranslation, 0, 250, Easing.CubicOut);
if(DeviceInfo.Platform == DevicePlatform.MacCatalyst)
{
if(layout.IsVisible)
(layout as IView).InvalidateMeasure();
}
}

@vishnumenon2684 vishnumenon2684 removed their assignment Feb 13, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter p/2 Work that is important, but is currently not scheduled for release partner/syncfusion Issues / PR's with Syncfusion collaboration platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants