I bind string property from view model class on image source in view. String property can have value 1 for man and 2 for woman. I use also converter on binding which returns uri for image source.
In view I have this:
<Image Style="{StaticResource InfoIcon}"
Source="{Binding ., Mode=OneWay,UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource sexImgConverter},
ConverterParameter=Oponent.Info.Sex}"/>
Converter method is here:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
const string woman = "/images/icons/chat/woman.png";
const string man = "/images/icons/chat/man.png";
string result = string.Empty;
string result = int.Parse(value.ToString()) == 1 ? man : woman;
return new Uri(result);
}
Problem is I bind property sex (in view Oponent.Info.Sex) which is type string and parse to integer.
But if I add debuger break point on line :
string resul = int.Parse(value.ToString()) == 1 ? man : woman;
I see that value is type of my view model class.
I try use this convert method no another bind, here is it:
<TextBlock Style="{StaticResource InfoText}">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}, {1} rokov">
<Binding Path="Oponent.Info.Sex" Converter="{StaticResource sexConverter}"/>
<Binding Path= "Oponent.Info.Age"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
I use the same conveter add debuger break point on line:
string resul = int.Parse(value.ToString()) == 1 ? man : woman;
I see the value is type of string.
What have I done wrong?