【发布时间】:2020-01-31 14:36:19
【问题描述】:
我有问题。我创建了一个 CollectionView,其中包含一个带有图像的列表。 myImage 类如下所示:
public class myImage
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public string Type { get; set; }
[XmlIgnore]
public ImageSource imageSource { get; set; }
}
现在在 CollectionView 中,我还有一个带有大小列表的选择器。该类如下所示:
public class Format
{
public int Id { get; set; }
public string Size{ get; set; }
public float Price { get; set; }
public string Type { get; set; }
}
我想要的是,当 myImage.Type 具有特定值(例如“type1”)时,选择器中的唯一选项将是 Format.Type="type1" 的大小。其余的,除了Format.Type = "type1"的格式外,整个列表都可以显示在选择器中。
所以我想要一个带有图像的 CollectionView,在图像旁边有一个选择器。如果 myImage.Type="type1" 选择器将填充 Type="type1" 的格式。图像的其余部分获取 Format.Type="Normal" 的格式。
这是我的 xaml:
<DataTemplate>
<Grid HeightRequest="100" VerticalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="3"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="3"/>
</Grid.ColumnDefinitions>
<ff:CachedImage Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" Aspect="AspectFill" Source="{Binding imageSource}" />
<Picker Grid.Row="0" Grid.RowSpan="2" Grid.Column="3" Title="Formaat" HorizontalOptions="FillAndExpand"
ItemsSource="{Binding Source={RelativeSource AncestorType={x:Type vm:VM_FotoLijst}}, Path=formaatList}"
ItemDisplayBinding="{Binding Size}" PropertyChanged="FormaatPicker_PropertyChanged"/>
</Grid>
</DataTemplate>
我该怎么做?
【问题讨论】:
-
我不确定我是否理解。因此,您希望根据 Type 是否具有特定值来更改选择器中显示的数据。
-
是的,这就是我想要的
标签: c# xamarin xamarin.forms xamarin.android xamarin.ios