Если у меня есть простое изображение в XAML:
<Image
Source="{Binding ImageUrl}"
Grid.Column="0"
HorizontalOptions="EndAndExpand"
VerticalOptions="CenterAndExpand" />
путь к файлу привязан правильно. Однако, если я вложу элемент Image в CollectionView, изображение больше не будет связываться.
<CollectionView
x:Name="CV"
ItemsSource="{Binding ThumbnailPhotos}"
VerticalOptions="Center"
HorizontalOptions="Center">
<CollectionView.ItemsLayout>
<GridItemsLayout
Orientation="Vertical"
Span="2" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame
BorderColor="LightGray"
CornerRadius="3"
HasShadow="False">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<Image
Source="{Binding ImageUrl}"
Grid.Column="0"
HorizontalOptions="EndAndExpand"
VerticalOptions="CenterAndExpand" />
</Grid>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Для целей тестирования ObservableCollection в моей ViewModel выглядит так:
ThumbnailPhotos = new ObservableCollection<Thumbnail>
{
new Thumbnail(){ ImageUrl = "/Users/<myUser>/Library/Developer/CoreSimulator/Devices/68BF4E8E-DF6D-4459-B6AD-DCEDB270916B/data/Containers/Data/Application/0C205001-6DFD-4846-9E6D-415F772FCB58/Documents/Defect Photos/IMG_20190102_165617/IMG_20190102_165617.jpg" } ,
new Thumbnail(){ ImageUrl = "/Users/<myUser>/Library/Developer/CoreSimulator/Devices/68BF4E8E-DF6D-4459-B6AD-DCEDB270916B/data/Containers/Data/Application/0C205001-6DFD-4846-9E6D-415F772FCB58/Documents/Defect Photos/IMG_20190102_165617/IMG_20190102_165617.jpg" } ,
new Thumbnail(){ ImageUrl = "/Users/<myUser>/Library/Developer/CoreSimulator/Devices/68BF4E8E-DF6D-4459-B6AD-DCEDB270916B/data/Containers/Data/Application/0C205001-6DFD-4846-9E6D-415F772FCB58/Documents/Defect Photos/IMG_20190102_165617/IMG_20190102_165617.jpg" } ,
new Thumbnail(){ ImageUrl = "/Users/<myUser>/Library/Developer/CoreSimulator/Devices/68BF4E8E-DF6D-4459-B6AD-DCEDB270916B/data/Containers/Data/Application/0C205001-6DFD-4846-9E6D-415F772FCB58/Documents/Defect Photos/IMG_20190102_165617/IMG_20190102_165617.jpg" } ,
};