Bug 42531 - Adding ResourceDictionary to ViewCell within ListView errors when using Xamlc
Summary: Adding ResourceDictionary to ViewCell within ListView errors when using Xamlc
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.1
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-13 18:09 UTC by James
Modified: 2017-01-25 14:53 UTC (History)
4 users (show)

Tags: ac
Is this bug a regression?: No
Last known good build:


Attachments
Sample App with issue (393.21 KB, application/x-zip-compressed)
2016-07-13 18:09 UTC, James
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 FIXED

Description James 2016-07-13 18:09:34 UTC
Created attachment 16651 [details]
Sample App with issue

Using the following XAML:

<StackLayout>
    <ListView>
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <ContentView Padding="5">
              <Frame OutlineColor="Accent"
                     Padding="10">
                <StackLayout Orientation="Horizontal">
                  <StackLayout.Resources>
                    <ResourceDictionary>
                      <Style TargetType="Label">
                        <Setter Property="HorizontalOptions" Value="Center"/>
                      </Style>
                    </ResourceDictionary>
                  </StackLayout.Resources>
                  <StackLayout>
                    <Label Text="Example1"/>
                    <Label Text="2..."/>
                  </StackLayout>
                </StackLayout>
              </Frame>
            </ContentView>
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
  </StackLayout>

If you enable the Xaml compiler it will error at the line

<Setter Property="HorizontalOptions" Value="Center"/>

with the following: "Error: No property, bindable property, or event found for 'Property'"

Compiles and runs file if disabled.
Comment 1 James 2016-07-13 20:09:52 UTC
A simplified version of the code can be found here, cleaned out some of the extra

    <ListView>
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <ViewCell.Resources>
              <ResourceDictionary>
                <Style TargetType="Label">
                  <Setter Property="HorizontalOptions" Value="Center"/>
                </Style>
              </ResourceDictionary>
            </ViewCell.Resources>
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
Comment 2 Stephane Delcroix 2017-01-25 14:36:34 UTC
the example in #c1 is invalid. ViewCell doesn't have a Resources property
Comment 3 Stephane Delcroix 2017-01-25 14:53:00 UTC
I no longer can reproduce this. I guess this was fixed as a side effect of another fix.

I've added a test to avoid regression in the future https://github.com/xamarin/Xamarin.Forms/commit/ccc99315beb6f9effc8ad2c8f78cedf98534cec2

I'm closing this as fixed, please reopen if you can reproduce this on 2.3.4-pre2