Metro App ListView SelectedItem Selected VisualState

橙三吉。 提交于 2019-11-29 08:52:11

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}}"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!