xamarin/Xamarin.Forms

Using multiple ToolbarItem or MenuItem instances disables compiled bindings

Offen

#5.762 geöffnet am 30.03.2019

 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (1.926 Forks)batch import
a/binding ⛓a/listviewe/4 :clock4:help wantedinactivet/bug :bug:up-for-grabs

Repository-Metriken

Stars
 (5.644 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Description

Using multiple ToolbarItem or MenuItem instances disables compiled bindings.

The following code compiles, as it should:

                <ListView.ItemTemplate>
                    <DataTemplate x:DataType="local:MainPageDataValue">
                        <TextCell Text="{Binding Value}">
                            <TextCell.ContextActions>
                                <MenuItem Text="{Binding ValueMenuItem}" />
                            </TextCell.ContextActions>
                        </TextCell>
                    </DataTemplate>
                </ListView.ItemTemplate>

The following code triggers a compiler error, as it should:

                <ListView.ItemTemplate>
                    <DataTemplate x:DataType="local:MainPageDataValue">
                        <TextCell Text="{Binding Value}">
                            <TextCell.ContextActions>
                                <MenuItem Text="{Binding ValueMenuItemBUGBUG}" />
                            </TextCell.ContextActions>
                        </TextCell>
                    </DataTemplate>
                </ListView.ItemTemplate>

However, the following code also compiles, because the XAML compiler isn't used when there are multiple MenuItem instances:

                <ListView.ItemTemplate>
                    <DataTemplate x:DataType="local:MainPageDataValue">
                        <TextCell Text="{Binding Value}">
                            <TextCell.ContextActions>
                                <MenuItem Text="{Binding ValueMenuItemBUGBUG}" />
                                <MenuItem Text="TEXT" /> <!-- Remove this and see a compile error -->
                            </TextCell.ContextActions>
                        </TextCell>
                    </DataTemplate>
                </ListView.ItemTemplate>

Steps to Reproduce

In a page with compiled bindings, add multiple ToolbarItem or MenuItem instances.

Expected Behavior

Compiled bindings are enabled. Bindings to non-existent properties will fail at compile time.

Actual Behavior

Compiled bindings are disabled.

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE: VS 2017
  • Platform Target Frameworks:
    • Android: 8.1

Reproduction Link

XamarinFormsSample.zip

Contributor Guide