Bug 46503 - Setting style on ImageCell or TextCell does not take effect
Summary: Setting style on ImageCell or TextCell does not take effect
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 25547 ()
Depends on:
Blocks:
 
Reported: 2016-11-04 17:14 UTC by Robert
Modified: 2017-08-18 17:43 UTC (History)
6 users (show)

Tags: bug, ios, android, uwp, implicit style, textcell, imagecell, cell, ac
Is this bug a regression?: ---
Last known good build:


Attachments
repro project (295.58 KB, application/x-zip-compressed)
2017-03-17 19:15 UTC, Jimmy [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 46503 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Robert 2016-11-04 17:14:48 UTC
I am trying to set a default style for ImageCell and TextCell. I have two styles set right now,

      <Color x:Key="PrimaryColor">#F38520</Color>

      <Style TargetType="ImageCell">
        <Setter Property="TextColor" Value="{DynamicResource PrimaryColor}" />
      </Style>
      <Style TargetType="TextCell">
        <Setter Property="TextColor" Value="{DynamicResource PrimaryColor}" />
      </Style>

They are set to be global and apply to all image cells and text cells. The code compiles fine, but none of my image cells or text cells have the color changed.
Comment 1 TRO Solo 2017-03-13 09:15:26 UTC
I have the same problem and I think this will not work by design because the Style property is defined within the VisualElement class (see https://developer.xamarin.com/api/type/Xamarin.Forms.VisualElement/), but the Cell class derives from the Element class (see https://developer.xamarin.com/api/type/Xamarin.Forms.Element/). This can be seen on the visual class hierarchy image on the latter link, too.

To verify that this is true, you can just try to apply the Style within the XAML of the Page where your ListView or TableView is defined. In order to do so, you need to add an x:Key attribute to your Style within the ResourceDictionary. If you try to apply this style to any or each of your TextCells within the DataTemplate tag, the Style property will not be recognized.
Comment 2 TRO Solo 2017-03-13 09:19:19 UTC
Additionally, this has been reported in December 2014 by another user, but the bug report has been closed in early 2016 because the Xamarin.Forms team thought, that it does no longer affect the current version. IMHO they're wrong.
https://bugzilla.xamarin.com/show_bug.cgi?id=25547
Comment 3 Jimmy [MSFT] 2017-03-17 19:15:03 UTC
Created attachment 20445 [details]
repro project

I was able to reproduce this issue with the project I am attaching. This is occurring on iOS, Android, and UWP. I am confirming this report so the team can investigate further.


### Steps to Reproduce
1. Run the attached project on iOS, Android, or UWP


### Expected Results
The item's text will be green. To see the expected result, add set the TextColor property directly in the TextCell's xaml.


### Actual Results
The items are in their default color


### Version Tests
2.3.5.68-nightly    BAD
2.3.4-pre5          BAD
2.3.3.193           BAD
Comment 4 E.Z. Hart [MSFT] 2017-06-19 15:20:54 UTC
*** Bug 25547 has been marked as a duplicate of this bug. ***
Comment 5 Derek Foulk 2017-08-18 17:38:06 UTC
Hey dudes, just wanted to add here- this issue is affecting all cell types (EntryCell, TextCell, ImageCell, etc.). I can't get any styles to apply to any of them!
Comment 6 Derek Foulk 2017-08-18 17:43:58 UTC
This is issue is still affecting Xamarin.Forms 2.3.5.256-pre6. I didn't realize how old this bug is. Any chance this will be fixed before the next stable release?