简体   繁体   English

如何将属性绑定到 BindableLayout.ItemsSource 中的另一个 object

[英]How to bind property to another object inside BindableLayout.ItemsSource

I have BindableLayout, that binded to ViewModel property (which is actually a subclass), but inside this layout i'm trying to bind Command to VM another property.我有 BindableLayout,它绑定到 ViewModel 属性(实际上是一个子类),但在这个布局中我试图将 Command 绑定到 VM 另一个属性。 How can i specify property for binding in this case?在这种情况下如何指定绑定属性?

XAML code: XAML 代码:

    <Grid BindableLayout.ItemsSource="{Binding ActualValues}"
          Grid.Column="0"
          Grid.ColumnSpan="2"
          Grid.Row="0">
        <BindableLayout.ItemTemplate>
            <DataTemplate>
                <Frame Margin="{Binding Margin}">
                    <Entry TabIndex="{Binding Id}"
                           Text="{Binding Value}"
                           Placeholder="{Binding Placeholder}"
                           Style="{StaticResource EntryStyle}">
                        <Entry.Behaviors>
                            <behaviors:EntryCompletedBehavior Command="{Binding EntryCompletedCommand}"/> 
                        </Entry.Behaviors>
                    </Entry>
                </Frame>
            </DataTemplate>
        </BindableLayout.ItemTemplate>
    </Grid>

You could set the binding path in xaml您可以在 xaml 中设置绑定路径

in xaml在 xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:xxx"
             x:Class="xxx.MainPage"

             x:Name="page"  // set name of ContentPage 
             >
Command="{Binding Source={x:Reference page} , Path=BindingContext.xxxCommand}" 

xxxCommand is an ICommand which been defined in VM. xxxCommand是在 VM 中定义的 ICommand。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 BindableLayout.ItemsSource 设置为其他文件中的 ObservableCollection - How to set the BindableLayout.ItemsSource to an ObservableCollection in an other file 如何将ItemsSource绑定到私有属性 - How to bind an ItemsSource to a private property 如何将ItemsSource绑定到父窗口的ObservableCollection属性? - How to bind ItemsSource to ObservableCollection Property of the parent Window? 如何将ItemsControl的ItemsSource绑定到IEnumerable的T类内部的属性 <T> ? - How to bind ItemsControl's ItemsSource to a Property that is inside of class T from IEnumerable<T>? CollectionView 中的 CollectionView 未正确绑定 ItemsSource 属性 (XamarinForms) - CollectionView inside CollectionView doesn't bind ItemsSource property correctly (XamarinForms) 将WPF组合框项目源绑定到另一个.cs文件中的属性 - Bind WPF combobox itemssource to property in another .cs file 如何将Items绑定到ItemsSource? - How to bind Items to ItemsSource? WPF如何将图像作为ItemsSource的属性绑定到DataGrid列? - WPF How to Bind an Image to a DataGrid column as a property of the ItemsSource? 如何将嵌套 collectionView 的 ItemsSource 属性绑定到其中包含的 CollectionView 的项目? - How to bind the ItemsSource property of a nested collectionView to the item of the CollectionView in which is contained? 如何将ItemsControl.ItemsSource与XAML中的属性绑定? - How can I bind an ItemsControl.ItemsSource with a property in XAML?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM