xaml - 从嵌套的 RepeaterView 中获取 SelectedItem
问题描述
我正在使用嵌套在另一个中继器视图中的DottorPagliaccius 中继器视图。命令 RSSFeedSelectedCommand 除非在顶部中继器上否则不起作用,这在理论上是有道理的,但我怎样才能让它工作呢?
我已经研究过使用 Converters 和 bindtoeventcommand,但看不到让它们工作。
<repeater:RepeaterView x:Name="MainRepeater" SeparatorHeight="25" ItemsSource={Binding Feeds}">
<repeater:RepeaterView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Spacing="10">
<Label Text="{Binding Title}" TextColor="Blue" />
<Label Text="{Binding Description}" TextColor="Red" FontSize="12" />
<repeater:RepeaterView x:Name="MainRepeater2" EmptyText="No elements" ShowSeparator="true" SeparatorHeight="2" SeparatorColor="Silver" ItemsSource="{Binding Items}" SelectedItemCommand="{Binding RSSFeedSelectedCommand}">
<repeater`enter code here`:RepeaterView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Image Source="{Binding Image.Url}"></Image>
<StackLayout Orientation="Vertical">
<Label Text="{Binding Title}" TextColor="Black" />
<Label Text="{Binding Description}" TextColor="Black" FontSize="12" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</repeater:RepeaterView.ItemTemplate>
</repeater:RepeaterView>
</StackLayout>
</ViewCell>
</DataTemplate>
</repeater:RepeaterView.ItemTemplate>
</repeater:RepeaterView>
解决方案
中继器试图在其中找到命令,Feeds
但视图模型中存在。
<repeater:RepeaterView x:Name="MainRepeater2" EmptyText="No elements" ShowSeparator="true" SeparatorHeight="2" SeparatorColor="Silver" ItemsSource="{Binding Items}" SelectedItemCommand="{Binding Source={x:Reference RSSPage}, Path=BindingContext.RSSFeedSelectedCommand}">
你必须命名页面:
<ContentPage x:Name="PageName" />
推荐阅读
- python - 如何访问保存在桌面上的腌制模型文件到 Jupiter 笔记本?
- scala - 如何使用 Mockito 在 Scala 中以函数作为参数来部分模拟函数
- c# - 在mysql连接字符串中添加应用程序名称/程序名称
- ruby-on-rails - AWS::S3::Errors::InvalidAccessKeyId 安全令牌服务凭证不起作用
- javascript - NuxtJS:EmailJS 找不到依赖项“fs”
- ruby-on-rails - Rails 合并(和手动分配)分配 nil
- python - 如何处理python中的一些异常
- acumatica - 未绑定 DAC 处理屏幕
- ansible-2.x - 更新/修改列表中的嵌套字典值
- python - 使用 Python 和 Keras 调整 CSV 数据的大小