Reputation: 335
I'm trying to achieve the following
<controls:Carousel.ItemTemplate>
<DataTemplate>
<Image Width="200"
Height="200"
VerticalAlignment="Center"
Source="/Assets/DemoImages/123_DemoImage.jpg"
Stretch="Uniform" />
</DataTemplate>
</controls:Carousel.ItemTemplate>
Given the itemsource of
<controls:Carousel x:Name="CarouselControl" ItemsSource="{x:Bind PropertySearchList}"
and PropertySearchList is a
List<ToLetProperty> PropertySearchList
with the ToLetProperty class having a string property of FrontImage (and other properties)
for example :
Source="/Assets/DemoImages/{ToLetProperty.FrontImage}"
Upvotes: 0
Views: 364
Reputation: 3286
When we use {x:Bind}
with data templates, we must indicate the type being bound to by setting an x:DataType
value. We can set the base class type to it.
In the Image
control, we can use set FrontImage
property to the Source by the x:Bind
.
For example:
<controls:Carousel x:Name="CarouselControl" ItemsSource="{x:Bind PropertySearchList}" >
<controls:Carousel.ItemTemplate>
<DataTemplate x:DataType="local:ToLetProperty">
<Image Width="200" Height="200" VerticalAlignment="Center" Source="{x:Bind FrontImage}" Stretch="Uniform" />
</DataTemplate>
</controls:Carousel.ItemTemplate>
</controls:Carousel>
By the way, I suggest you use the ObservableCollection
to instead of List
. It represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
Upvotes: 2