Bug 37371 - Attached properties are not set on the custom controls
Summary: Attached properties are not set on the custom controls
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2016-01-04 06:50 UTC by Prashant Cholachagudda
Modified: 2016-09-09 07:51 UTC (History)
8 users (show)

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

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 FIXED

Description Prashant Cholachagudda 2016-01-04 06:50:20 UTC
I created a custom control that inherits from Xamarin.Forms.Button. In my
XAML, I have:

<controls:SymbolButton Text="&#xE010;" Grid.Column="3"
Clicked="BackKeyClicked" Style="{StaticResource BackKeyButton}" />


which displays the control properly. However, I really want this control in
a Grid, and I want the Row to be different based on platform.

If I try to add:

<controls:SymbolButton Text="&#xE010;" Grid.Column="3"
Clicked="BackKeyClicked" Style="{StaticResource BackKeyButton}">
<controls:SymbolButton.Grid.Row>
<OnPlatform x:TypeArguments="x:Int32" iOS="3"
Android="0"></OnPlatform>
</controls:SymbolButton.Grid.Row>
</controls:SymbolButton>

I get an error:

Type Grid not found in xmlns
clr-namespace:Itron.Mobile.Field.Common.CoreApplication.Controls;assembly=Itron.Mobile.Field.Common.CoreApplication

I also tried:

<controls:SymbolButton Text="&#xE010;" Grid.Column="3"
Clicked="BackKeyClicked" Style="{StaticResource BackKeyButton}">
<Button.Grid.Row>
<OnPlatform x:TypeArguments="x:Int32" iOS="3"
Android="0"></OnPlatform>
</Button.Grid.Row>
</controls:SymbolButton>

but get an error:
type grid not found

However, the following XAML using a standard button works just
fine:
<Button Text="&#xE010;" Grid.Column="3" Clicked="BackKeyClicked"
Style="{StaticResource BackKeyButton}">
<Button.Grid.Row>
<OnPlatform x:TypeArguments="x:Int32" iOS="3"
Android="0"></OnPlatform>
</Button.Grid.Row>
</Button>
Comment 1 Stephane Delcroix 2016-01-05 14:05:16 UTC
The syntax for setting an attached Bindable Property as xml element is like this:

<Button>
    <Grid.Row>2</Grid.Row>
</Button>

The attached property can be prefixed with a xml namespace if required.
I'm doing a quick check that it is correctly supported in your specific case before closing this issue.
Comment 2 Stephane Delcroix 2016-01-05 14:18:27 UTC
The correct syntax works for me, and should work for you.

Note that for now this won't work with XamlC ON. Fixing this is on our short list.
Comment 3 wayne.creasey 2016-01-05 21:22:01 UTC
got it. thanks!
Comment 4 Kevin B 2016-05-06 21:35:53 UTC
@Stephane Delcroix

I am still seeing this issue when using Xaml compile on version 4.2.0.21 (current Alpha). 

Any insight on when this might be fixed?