Skip to content

[BUG][8.0.x] Label is not displayed properly when adding TouchBehavior #1805

@tranb3r

Description

@tranb3r

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

When adding a TouchBehavior to a simple Grid layout, a Label inside the Grid is sometimes not displayed properly.
See screenshots, with or without TouchBehavior.

Screenshot_1712564434-b

Here is the xaml code for the ItemView:

<ContentView
    x:Class="MauiAppMctTouchBehaviorLabelTruncation.ItemView"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:mauiAppMctTouchBehaviorLabelTruncation="clr-namespace:MauiAppMctTouchBehaviorLabelTruncation"
    xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
    x:Name="ItemViewRef"
    x:DataType="mauiAppMctTouchBehaviorLabelTruncation:ItemViewModel">

    <Border
        Margin="10"
        Padding="10"
        BackgroundColor="LightCyan"
        Stroke="Black">

        <Border.Behaviors>
            <mct:TouchBehavior BindingContext="{Binding BindingContext, Source={x:Reference ItemViewRef}}" Command="{Binding TapCommand}" />
        </Border.Behaviors>

        <Grid ColumnDefinitions="*,Auto">
            <ContentView Grid.Column="2">
                <Label
                    BackgroundColor="LightGoldenrodYellow"
                    Text="{Binding Title}"
                    TextColor="Black" />
            </ContentView>
        </Grid>

    </Border>

</ContentView>

Expected Behavior

The Label should be displayed the same, with or without the TouchBehavior.

Steps To Reproduce

  1. Open the repro.
  2. When there is a TouchBehavior, some Items are not displayed properly.
  3. Remove the TouchBehavior, everything is back to normal.

Link to public reproduction project repository

https://github.com/tranb3r/Issues/tree/main/MauiAppMctTouchBehaviorLabelTruncation

Environment

- .NET MAUI CommunityToolkit:8.0.x
- OS:Android
- .NET MAUI:8.0.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/behaviorsIssue/Discussion/PR that has to do with BehaviorsbugSomething isn't workingunverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions