xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] Style not applied on ViewCell in a TableView #7062

Open MSeifert04 opened 5 years ago

MSeifert04 commented 5 years ago

Description

It seems like styles defined in a css file don't apply to contents of a viewcell in a tableview

Steps to Reproduce

New Mobile Application (Xamarin forms) in Visual Studio then this in the MainPage.xaml:

    <ContentPage.Resources>
        <StyleSheet Source="/Styles/AppStyle.css" />
    </ContentPage.Resources>

    <StackLayout>
        <Label Text="Error!" StyleClass="error" />
        <TableView Intent="Form">
            <TableRoot>
                <TableSection>
                    <ViewCell>
                        <StackLayout Orientation="Horizontal">
                            <Label Text="Test" />
                            <Entry Placeholder="Enter something" />
                            <Label Text="Error" StyleClass="error" />
                        </StackLayout>
                    </ViewCell>
                </TableSection>
            </TableRoot>
        </TableView>
    </StackLayout>

and this in the Styles/AppStyle.css:

Label.error {
    color: red;
}

Expected Behavior

Both Label with the StyleClass="error" should have a text-color of red.

Actual Behavior

The text in the Label inside the tableview is black.

Basic Information

I haven't actually tested this against multiple devices, just with the one android emulator (on Windows) that I use.

Screenshots

Screenshot_1564845478

jfversluis commented 5 years ago

This seems to have happened before, at least for ListView in #1472. I have created a little repro project that shows this

Repro7062.zip

ianthetechie commented 3 years ago

This is (somewhat recently?) broken for the header of ListViews as well. Just got a message from a client to restyle a view which I agreed looked uncharacteristically bad in their app. It turns out that the StyleClass on the Label elements in the list header are suddenly being ignored.