This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 30765 - Styles with Frames does not apply the "Padding" property
Summary: Styles with Frames does not apply the "Padding" property
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 1.4.4
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2015-06-04 00:26 UTC by Tyler_hartwig
Modified: 2017-03-21 17:19 UTC (History)
13 users (show)

See Also:
Tags: AC
Is this bug a regression?: ---
Last known good build:


Attachments
Test Project displaying bug (64 bytes, text/plain)
2015-06-04 00:36 UTC, Tyler_hartwig
Details
Quick fix for Jason (324.38 KB, patch)
2016-04-22 12:20 UTC, n.podbielski
Details | Diff

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 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 Mathieu.F 2017-03-21 17:19:52 UTC
Ran into this on 2.3.3.193

Note You need to log in before you can comment on or make changes to this bug.