Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Android] Draw() not called if GraphicsView is child of a ScrollView with Orientation different from Vertical #18416

Open
riccardominato opened this issue Oct 29, 2023 · 2 comments
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@riccardominato
Copy link

riccardominato commented Oct 29, 2023

Description

If you put a GraphicsView inside a ScrollView and set Orientation to a value different from the default Vertical, the Draw() method of the IDrawable associated seems not to be called.

Steps to Reproduce

  1. Create a new .NET MAUI app.
  2. Edit the main page in this way.

MainPage.xaml

<?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="GraphicsViewInScrollView.MainPage">

    <!-- Set Orientation to a value different from Vertical -->
    <ScrollView
        Orientation="Both"
        BackgroundColor="LightGray">
        <GraphicsView
            x:Name="GraphicsView" />
    </ScrollView>

</ContentPage>

MainPage.xaml.cs

namespace GraphicsViewInScrollView;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        GraphicsView.Drawable = new MyDrawable();
    }
}
  1. Add this Drawable cs file.

MyDrawable.cs

namespace GraphicsViewInScrollView;

public class MyDrawable : IDrawable
{
    public void Draw(ICanvas canvas, RectF dirtyRect)
    {
        canvas.DrawString("Hello World", 0, 0, dirtyRect.Width, dirtyRect.Height, HorizontalAlignment.Left, VerticalAlignment.Top);
    }
}

Expected behavior
Screenshot_1698578938

Actual behavior
Screenshot_1698578777

Link to public reproduction project repository

https://github.com/Riccardo11/MauiIssues/tree/main/GraphicsViewInScrollView

Version with bug

8.0.0-rc.2.9373

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 13. Didn't test other Android versions.

Did you find any workaround?

Setting GraphicsView WidthRequest to a value.

<GraphicsView
    WidthRequest="500"
    x:Name="GraphicsView" />

Relevant log output

No response

@riccardominato riccardominato added the t/bug Something isn't working label Oct 29, 2023
@riccardominato riccardominato changed the title [Android] Draw() not called if GraphicsView is child of a ScrollView with Orientation different from Vertical [Android] Draw() not called if GraphicsView is child of a ScrollView with Orientation different from Vertical Oct 29, 2023
@riccardominato
Copy link
Author

I noticed that setting WidthRequest of GraphicsView to a value the problem doesn't appear.
Cannot say if this is really a bug, anyway it surely has a misleading behavior.

@Eilon Eilon added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Oct 30, 2023
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Oct 31, 2023
@XamlTest
Copy link

Verified this on Visual Studio Enterprise 17.8.0 Preview 5.0(8.0.0-rc.2.9373). Repro on Android 14.0-API34, not repro on Windows 11 and iOS 16.4 with below Project:
GraphicsViewInScrollView.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/android 🤖 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

5 participants