Bug 31324 - Using a x:Name in a style on the xaml resources side causes controls to be created in the generated file.
Summary: Using a x:Name in a style on the xaml resources side causes controls to be cr...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.4
Hardware: PC Windows
: Low minor
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2015-06-23 10:50 UTC by Brad Chase
Modified: 2015-07-30 13:12 UTC (History)
5 users (show)

Tags: AC Xaml namescope
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:
VERIFIED FIXED

Description Brad Chase 2015-06-23 10:50:13 UTC
Discussion on the defect:
https://forums.xamarin.com/discussion/comment/134175#Comment_134175


Xaml side:
    <ContentView xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:Controls="clr-Library.Controls;assembly=Library"
                x:Class="Library.Controls.TabItem">
<ContentView.Resources>

    <ResourceDictionary>
    <Style x:Key="InternalStyle" TargetType="Controls:TabItem" >
        <Setter Property="HeaderContainer">
        <Setter.Value>
            <Grid VerticalOptions="Start" BackgroundColor="Red">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid x:Name="HeaderContainerElement" VerticalOptions="Start"/>
            <Grid x:Name="SelectedElement" BackgroundColor="#20FFFFFF" Grid.Row="1" HeightRequest="2"   VerticalOptions="Start" HorizontalOptions="Fill"/>
            </Grid>
        </Setter.Value>
        </Setter>
    </Style>
    </ResourceDictionary>

</ContentView.Resources>
</ContentView>


g.cs side:

//------------------------------------------------------------------------------
// 
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 
//------------------------------------------------------------------------------

namespace Library.Controls {
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

public partial class TabItem : ContentView {

    private Grid HeaderContainterElement;

    private Grid SelectedElement;

    private void InitializeComponent() {
        this.LoadFromXaml(typeof(TabItem));
        HeaderContainterElement = this.FindByName<Grid>("HeaderContainterElement");
        SelectedElement = this.FindByName<Grid>("SelectedElement");
    }
}
}

As we can see, the HeaderContainerElement and SelectedElement dont actually exist.  They are being created accidentally.
Comment 2 Jason Smith [MSFT] 2015-06-26 02:39:40 UTC
Should be fixed in 1.4.4-pre1
Comment 3 Parmendra Kumar 2015-07-20 05:20:46 UTC
I have checked this issue with X.F 1.4.4-pre2 and I am still getting issue.

Hence closing this issue.

Please reopen this issue if you facing same issue.

Thanks.
Comment 4 Parmendra Kumar 2015-07-30 13:12:17 UTC
An update for comment #3

I have checked this issue with X.F 1.4.4-pre2 and I am not getting this issue anymore.

Hence closing this issue.

Please reopen this issue if you facing same issue.

Thanks.