Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 元素TextBlock WP 7上的未知属性前景_C#_Silverlight_Xaml_Windows Phone 7_Ivalueconverter - Fatal编程技术网

C# 元素TextBlock WP 7上的未知属性前景

C# 元素TextBlock WP 7上的未知属性前景,c#,silverlight,xaml,windows-phone-7,ivalueconverter,C#,Silverlight,Xaml,Windows Phone 7,Ivalueconverter,前景上的未知属性 元素文本块 我有这个错误,当我试图 根据需要更改前景色 关于“阅读状态” 在Xaml中 <TextBlock Foreground="{Binding Converter={StaticResource ReadConverter},ConverterParameter={Binding Read_State}}" Text="{Binding Path=TexT}" Style="{StaticResource PhoneTextNormalStyle}" TextW

前景上的未知属性 元素文本块

我有这个错误,当我试图 根据需要更改前景色 关于“阅读状态”

在Xaml中

<TextBlock Foreground="{Binding Converter={StaticResource ReadConverter},ConverterParameter={Binding Read_State}}"  Text="{Binding Path=TexT}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>

这个错误可能有点误导。不能在转换器参数上使用绑定

您无法使用转换器,根本不需要转换器参数。您的转换器代码应该如下所示:-

    public class ReadConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ReadState =(bool)value;
                if (ReadState == false)
                    return new SolidColorBrush(Colors.Black);// new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
                else
                    return new SolidColorBrush(Colors.Black);

        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
以及您的Xaml:-

 <TextBlock Foreground="{Binding Read_State, Converter={StaticResource ReadConverter}}"  Text="{Binding Path=TexT}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>


您可能还希望阅读此文件以备将来使用。

与实际问题无关,您为什么要将read\u状态传递给ConverterParameter而不是绑定到ConverterParameter,并在转换器中使用value而不是parameter?read\u状态为bool,此值表示消息是否已读取。我有一个消息列表框,需要根据读取状态更改消息的颜色
 <TextBlock Foreground="{Binding Read_State, Converter={StaticResource ReadConverter}}"  Text="{Binding Path=TexT}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>