Bug 52310 - XAML Style override ignored
Summary: XAML Style override ignored
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2017-02-04 12:46 UTC by Philipp Sumi
Modified: 2017-05-30 14:14 UTC (History)
2 users (show)

Tags: xaml styles
Is this bug a regression?: ---
Last known good build:


Attachments
sample project (26.07 KB, application/zip)
2017-02-12 03:01 UTC, David Ortinau [MSFT]
Details
File with structure that fails (13.10 KB, application/xaml+xml)
2017-03-25 12:39 UTC, Philipp Sumi
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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Philipp Sumi 2017-02-04 12:46:09 UTC
I cannot override properties in styles it appears:


    <Label Style="{StaticResource RideItemLabelStyle}"
           FormattedText="{Binding LongText}"
           LineBreakMode="WordWrap" /> 


This label still does tail truncation if that property is set in the applied style. It appears the style takes precedence over the explicitly set property override.
Comment 1 David Ortinau [MSFT] 2017-02-12 03:01:46 UTC
Created attachment 19793 [details]
sample project

I'm not able to reproduce this with 2.3.4.192-pre2. Please provide more info and modify the project to demonstrate the issue.
Comment 2 Philipp Sumi 2017-03-25 12:15:41 UTC
Just ran into this again, with the label not wrapping properly:

Style:

            <Style x:Key="RowStyle"
                   TargetType="Label">
                <Setter Property="FontSize"
                        Value="{StaticResource StandardTextFontSize}" />
                <Setter Property="VerticalTextAlignment"
                        Value="Center" />
                <Setter Property="VerticalOptions"
                        Value="Center" />
                <Setter Property="HorizontalTextAlignment"
                        Value="Start" />
                <Setter Property="HorizontalOptions"
                        Value="Start" />
                <Setter Property="LineBreakMode"
                        Value="TailTruncation" />
            </Style>


Usage:

                    <Label Style="{StaticResource RowStyle}"
                           IsVisible="{Binding ShowDescription}"
                           Text="{Binding Ride.Description}"
                           LineBreakMode="WordWrap"
                           Grid.Row="15"
                           Grid.Column="1" />


This label doesn't wrap until I remove the TailTruncation directive from the style it uses. Maybe noteworthy: The style is in the same file as the label (resources section of the containing ContentView).

I'll attach the full XAML file.
Comment 3 Philipp Sumi 2017-03-25 12:37:28 UTC
Edit: I moved the snippet into your sample application and it wraps there. No idea why, it appears the control hierarchy plays into this somehow. I'll fold and just remove the LineBreakMode setters from my styles :/
Comment 4 Philipp Sumi 2017-03-25 12:39:46 UTC
Created attachment 20843 [details]
File with structure that fails

This is the control that doesn't wrap. The label in question is the last one with the following name: Label x:Name="MISSINGWRAP"
Comment 5 Philipp Sumi 2017-03-25 14:06:59 UTC
Note: My current workaround was to just override the LineBreakMode in another style rather than the control itself. This worked:

            <Style x:Key="WordWrappingRowStyle"
                   BasedOn="{StaticResource RowStyle}"
                   TargetType="Label">
                <Setter Property="LineBreakMode"
                        Value="WordWrap" />
            </Style>
Comment 6 David Ortinau [MSFT] 2017-05-25 14:03:56 UTC
Assigning to Stephane.
Comment 7 Stephane Delcroix 2017-05-30 13:51:40 UTC
Could you please provide the simplest possible project triggering this issue ?

Thanks a lot
Comment 8 Stephane Delcroix 2017-05-30 13:52:54 UTC
e.g., starts with david sample, and add your style until it fails
Comment 9 Philipp Sumi 2017-05-30 13:56:02 UTC
Sorry Stephane. I submitted that issue months ago and resolved the issue with the custom style override, which I can totally live with. Apart from the code I posted, I don't have anything anymore.
Comment 10 David Ortinau [MSFT] 2017-05-30 14:14:02 UTC
I tried again real quickly with tweaks guided by the newer xaml (Grid layout in particular). I still cannot reproduce this issue.

Let's close this for the time being since we cannot reproduce it, and please reopen it with a "simplest possible project".