Finally RESOLVED this, thanks to this article for giving me the idea:
http://blog.davemdavis.net/2012/11/12/controlling-the-datatemplate/
Created a BooleanToColourConverter
public sealed class BooleanToColourConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return (value is bool && (bool)value) ? AppResources.TertiaryColourBrush : AppResources.PrimaryColourBrush;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value is SolidColorBrush && ((SolidColorBrush)value).Color == AppResources.TertiaryColourBrush.Color;
}
}
Added this in App.xaml
<common:BooleanToColourConverter x:Key="BooleanToColourConverter"/>
Then used it like this:
Foreground="{Binding Tag, Converter={StaticResource BooleanToColourConverter}, Mode=TwoWay, RelativeSource={RelativeSource Mode=TemplatedParent}}"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…