Hi All,
Hi I am using Control template to display listbox items. I want to set the visibility of the control based on the item value.
I need the same http://efreedom.com/Question/1-424562/Can-Replace-Image-WPF-Grid-Another-Control-Depending-Source-Data
How to include this option in my code. (If the image source [ImgUrl] value is null i want to set the textblock [txtblkImg] visibility to collapse.)
My Code:
<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" Grid.Row="0" VerticalAlignment="Center" x:Name="img" Source="{Binding ImageUrl}" Height="74" Stretch="Fill" Width="75"/>
<TextBlock TextWrapping="WrapWithOverflow" Background="LightGreen" FontSize="10" Name="txtblkImg" HorizontalAlignment="Center" VerticalAlignment="Center" Height="74" Width="75">
<TextBlock Text="{Binding Title}"/><LineBreak/><LineBreak/>
<TextBlock Text="by "/>
<TextBlock Text="{Binding Author1}"/>
</TextBlock>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>