Reputation: 5936
I am developing a Windows 8.1 universal app.
i am using images in my grid view which is again bounded to some application model. Now i want to add overlay(decorator) on images depending on some condition in my model. is it possible to do so ?
cheers, Saurav
Upvotes: 0
Views: 433
Reputation: 81
If you don't already do it, you should put your image in the GridView.ItemTemplate. And then add your overlay whith the visibility set depending on the condition with the help of a converter.
<GridView.ItemTemplate>
<DataTemplate>
<Grid>
<Image Source="{Binding YourSource}" /> <!-- your image -->
<Image Source="{Binding OverlaySource}" Visibility="{Binding IsOverlayVisibleBoolean, Converter={StaticResource BooleanToVisibleConverter}" />
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
And your converter :
public class BooleanToVisibleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is Boolean)
return (Boolean)value ? Visibility.Visible : Visibility.Collapsed;
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
Upvotes: 1