binding image with 2 values with convertor
Posted
by prince23
on Stack Overflow
See other posts from Stack Overflow
or by prince23
Published on 2010-05-19T19:36:21Z
Indexed on
2010/05/19
20:10 UTC
Read the original article
Hit count: 227
Silverlight
|silverlight-4.0
hi, is it possiable to set 2 data field for an image control whiling binding
**<Image Source="{Binding ItemID, Converter={StaticResource IDToImageConverter}}" Height="50" />**
now here i need to add one more value Price now. need to send even price as an paramter for IDToImageConverter function
how can i do it?
now i need to check first price value there are 3 condition i neeed to check
in my IDToImageConverter function
if( price> 5o)
{
// then get the ItemID based on the value bind image here
if(ItemID >20)
{
// bind image1
}
if(ItemID >50)
{
// bind image2
}
}
if( price> 100)
{
// as above codition we do here
}
now how can i add these above functionality in IDToImageConverter ? any idea how i can solve it
<Image Source="{Binding ItemID, Converter={StaticResource IDToImageConverter}}" Height="50" />
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
</data:DataGrid>
public class IDToImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Uri uri = new Uri("~/Images/" + value.ToString()+ ".jpg", UriKind.Relative);
return new BitmapImage(uri);
}
thanks in advance. for anyhelp you provide prince
© Stack Overflow or respective owner