Bug 30765

Summary: Styles with Frames does not apply the "Padding" property
Product: Forms Reporter: Tyler_hartwig
Component: FormsAssignee: Stephane Delcroix <stephane.delcroix>
Status: RESOLVED FIXED    
Severity: normal CC: adrianknight89, alberto, andree.romoth, david, eric.maupin, fiyahuluw, jas, mark.curtis, mathieu.fillion, mike, n.podbielski, nathan.castle, seth.rosetter, stephane.delcroix, tim.ahrentlov
Priority: Normal    
Version: 1.4.4   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS   
Tags: AC Is this bug a regression?: ---
Last known good build:
Attachments: Test Project displaying bug
Quick fix for Jason

Description Tyler_hartwig 2015-06-04 00:26:42 UTC
When writing a Xamarin.Forms app using XAML and Styles, the Padding property of a style is not applied for Frame views.  I have attempted this on both iOS and Android, and neither apply this particular style property.  Here is the XAML code I created, it is also in the attached project.  

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="FormsFrameBug.FramesPage">
	<ContentPage.Resources>
		<ResourceDictionary>
			<Style TargetType="Frame">
				<Setter Property="Padding" Value="0" />
				<Setter Property="VerticalOptions" Value="CenterAndExpand" />
			</Style>
			<Style TargetType="Frame" x:Key="ExplicitStyle">
				<Setter Property="Padding" Value="0" />
				<Setter Property="VerticalOptions" Value="CenterAndExpand" />
			</Style>
		</ResourceDictionary>
	</ContentPage.Resources>
	<ContentPage.Content>
		<StackLayout>
			<Frame BackgroundColor="Blue">
				<BoxView BackgroundColor="Red" />
			</Frame>
			<Frame Style="{StaticResource ExplicitStyle}" BackgroundColor="Yellow">
				<BoxView BackgroundColor="Red" />
			</Frame>
			<Frame BackgroundColor="Lime" Padding="0">
				<BoxView BackgroundColor="Red" />
			</Frame>
		</StackLayout>
	</ContentPage.Content>
</ContentPage>

I believe each of the Frame Views in this stack layout should be rendered identically, as each of their padding properties should be 0.  The sample also displays that the issue occurs with both implicit and explicit styles.
Comment 1 Tyler_hartwig 2015-06-04 00:31:56 UTC
I also failed to mention that I have experienced this both in a PCL Project and a Shared Project, in case that is relevant
Comment 2 Tyler_hartwig 2015-06-04 00:36:54 UTC
Created attachment 11458 [details]
Test Project displaying bug
Comment 3 Nathan Castle 2015-09-24 21:27:13 UTC
A user in the forum ran into this issue (http://forums.xamarin.com/discussion/51824/frame-padding-can-it-still-be-changed). I can confirm that it is still present in 1.5.0.
Comment 4 adrianknight89 2016-01-28 23:20:28 UTC
I have this issue as well. This shouldn't be too difficult to fix. Not sure why it's been months without progress.
Comment 5 Jason Smith [MSFT] 2016-04-09 01:28:24 UTC
Because it presents a backwards compat issue and a proper fix requires work into the binding system :/

It's still on our list.
Comment 6 n.podbielski 2016-04-22 11:54:10 UTC
>and a proper fix requires

Then do *unproper* fix. Seriously you are adding new features every major release and can't fix this that kind of annoying bugs.
Comment 7 n.podbielski 2016-04-22 12:19:15 UTC
Here is @Jason quick fix for you (add this method to Frame class and you done):

protected override void OnPropertyChanged(string propertyName = null)
        {
            base.OnPropertyChanged(propertyName);
            if (propertyName == StyleProperty.PropertyName)
            {
                if (Style.Setters.Any(s => s.Property == PaddingProperty))
                {
                    Padding = (Thickness)Style.Setters.First(s => s.Property == PaddingProperty).Value;
                }
            }
        }
Comment 8 n.podbielski 2016-04-22 12:20:29 UTC
Created attachment 15817 [details]
Quick fix for Jason
Comment 9 tim.ahrentlov 2016-07-14 17:07:09 UTC
Just ran into this as well in 2.3-pre2. I believe a fix is due.
Comment 10 Mat 2017-03-21 17:19:52 UTC
Ran into this on 2.3.3.193
Comment 11 Stephane Delcroix 2017-05-30 08:20:39 UTC
see https://github.com/xamarin/Xamarin.Forms/pull/943
Comment 12 Stephane Delcroix 2017-06-01 07:55:36 UTC
will be fixed in 2.3.6-pre1
Comment 13 Andree Romoth 2017-08-30 12:58:00 UTC
I can reproduce this in 2.3.4.247 

Tested on:

iOS 10.3 Simulator, 
iPhone 6S iOS 9.3.5 
LG Nexus 5 Android 6.0.1

Applying Padding via Style does not work.
Comment 14 Andree Romoth 2017-08-30 13:10:30 UTC
Sorry,

read wrong version in comment above .. :D