Skip to content

ListView Invalid with ElementNameSubject binding #598

Closed

Description

@HaoLife
<Page
    x:Class="UnoControlsSample.Shared.Controls.CommandBarPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UnoControlsSample.Shared.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ios="http://uno.ui/ios"
    xmlns:android="http://uno.ui/android"
    xmlns:xamarin="http://uno.ui/xamarin"
    mc:Ignorable="d ios android xamarin"
    x:Name="CurrentPage"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <ListView Grid.Row="1" x:Name="recipes"  ItemsSource="{x:Bind Users}" Padding="5" Margin="0,20,0,0" 
                HorizontalContentAlignment="Stretch" 
                SelectionMode="None"
                IsItemClickEnabled="True" 
                >
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="Padding" Value="0" />
                <Setter Property="Margin" Value="0" />
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.ItemTemplate>
            <DataTemplate>
                <Button  Margin="0,5" Content="test command"  Command="{Binding DataContext.TestCommand,ElementName=CurrentPage}"/>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</Page>

I'm submitting a...

Using {Binding DataContext.TestCommand,ElementName=CurrentPage} in ListView is not recognized and can take effect in Android and UWP

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

Environment

Nuget Package: 

Package Version(s): 

Affected platform(s):
- [x] iOS
- [ ] Android
- [ ] WebAssembly
- [ ] Windows
- [ ] Build tasks

Visual Studio
- [x] 2017 (version: )
- [ ] 2017 Preview (version: )
- [ ] for Mac (version: )

Relevant plugins
- [ ] Resharper (version: )

Activity

  1. added
    kind/bug
    on Mar 6, 2019
  2. HaoLife commented on Apr 10, 2019

    @HaoLife
    Author

    @jeromelaban External members are bound in ListView, and member bindings outside ListView cannot be used in IOS as long as they are in ListView. Can we follow up on this issue?

    Example

            <TextBlock x:Name="title" Text="testing" />
    
            <ListView ItemsSource="{Binding Tests}" >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Text,ElementName=title}" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
    
  3. HaoLife commented on Apr 13, 2019

    @HaoLife
    Author

    NameScope.FindInNamescopes

    ListViewItem can't find the upper object after reloading parent.GetParent (), but can't find the bound object after reloading.

  4. HaoLife commented on Apr 13, 2019

    @HaoLife
    Author

    @jeromelaban The reason is that the Parent object is not a DependencyObject object, and the object first loaded is Windows.UI.Xaml.Controls.BlockLayout and then loaded again into the UIKit.UIView object.

  5. added
    platform/ios 🍎
    on May 22, 2019
  6. davidjohnoliver commented on Aug 8, 2019

    @davidjohnoliver
    Contributor

    fixed by #1064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugplatform/ios 🍎

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions