【发布时间】:2020-12-17 14:47:05
【问题描述】:
Sooo,我正在构建一个 Prism,xamarin.forms 应用程序。
我有一个名为“Herd”的对象,具有基本属性。
我正在显示这些对象的列表,并希望激活一个命令,将复选框中选中的牛群发送到视图模型。
<ListView
x:Name="UpdateHerdList"
ItemsSource="{Binding HerdsThatsNeedsToBeUpdated}"
RowHeight="60"
>
<ListView.ItemTemplate>
<DataTemplate>
<CustomRenderer:TransparentViewCell>
<Grid
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Label
TextColor="Black"
FontSize="15"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
Grid.Column="0"
Text="{Binding HeaderName}"
/>
<CheckBox
Grid.Column="1"
HorizontalOptions="Center"
ScaleX="1.75"
ScaleY="1.75"
Color="Black"
IsChecked="True"
>
<CheckBox.Behaviors>
<b:EventToCommandBehavior
EventName="PropertyChanged"
Command="{Binding UpdateThisHerdCommand}"
CommandParameter="{Binding Herd}"
/>
</CheckBox.Behaviors>
</CheckBox>
</Grid>
</CustomRenderer:TransparentViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
但我似乎找不到正确的方法来绑定到列表视图的 itemsource 内的视图模型。
有人可以帮助指导我正确的装订方式吗?
提前致谢!
【问题讨论】:
标签: c# xaml xamarin.forms mvvm