Hey guys i have this converter class :
public class InboxItemValueConverters : IValueConverter
{
public object Convert(object value, System.Type targetType,
object parameter, CultureInfo culture)
{
int urgency = (int)value;
Brush brush = new SolidColorBrush();
if (urgency == 0)
{
brush = new SolidColorBrush(Colors.Green); }
else if (urgency == 1)
{
brush = new SolidColorBrush(Colors.Yellow);
}
else if (urgency == 2)
{
brush = new SolidColorBrush(Colors.Red);
}
return brush;
}
public object ConvertBack(object value, System.Type targetType,
object parameter, CultureInfo culture)
{
return null;
}
public object ConvDateToShort(object value, System.Type targetType,
object parameter, CultureInfo culture)
{
DateTime DT = (DateTime)value;
return DT.ToShortDateString();
}
public object Convdateback(object value, System.Type targetType,
object parameter, CultureInfo culture)
{
return null;
}
}
and this is how i referenced it and used it the first time :
<src:InboxItemValueConverters x:Key="converttocolor" />
<Canvas Background="{Binding Urgency, Converter={StaticResource converttocolor}}"
no in the class,as you guys can see i have a date converter in there? how would i go around getting to that object through the xaml? want to convert date in another control, from same class
new xaml :
Text="{Binding DocDate , Converter={StaticResource converttocolor}}"
thanks in advance!
i am using visual studio 2012/windows phone 8/c#/silverlight
You have to move your date converter out of the colorconverter class into it’s own class
Then declare it at the top like you did your color converter and then change the converter to point to the date converter’s key