I am displaying images inside the list box. Binding the source of the image control using object through datacontext of the listbox.
Problem: I want to display No image (Image) if the url does't have image. Is it possible do it in the xaml code.
Code:
<ListBox ClipToBounds="False" x:Name="lbBestSellerImage" Width="Auto"
ItemsSource="{Binding}" ItemsPanel="{DynamicResource iptListBox}"
ItemContainerStyle="{DynamicResource ListBoxItemStyle}" />
<Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="2,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid Width="150">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" x:Name="img" Source="{Binding ImageUrl}" Height="74" Stretch="Fill" Width="75"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
No image
, or do you just want to have no image? – slugster