Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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# 更改列表框中数据索引文本块的前景色_C#_Data Binding_Windows Phone 8_Listbox_Foreground - Fatal编程技术网

C# 更改列表框中数据索引文本块的前景色

C# 更改列表框中数据索引文本块的前景色,c#,data-binding,windows-phone-8,listbox,foreground,C#,Data Binding,Windows Phone 8,Listbox,Foreground,我正试图根据绑定值更改ListBox中数据索引TextBlock的前景色 我的代码如下:xaml <Grid.Resources> <converters:ColorConverter x:Key="ColorConverter"/> </Grid.Resources> <ListBox> <ListBox.ItemTemplate> <DataTemplate> &

我正试图根据绑定值更改
ListBox
中数据索引
TextBlock
的前景色

我的代码如下:xaml

<Grid.Resources>
   <converters:ColorConverter x:Key="ColorConverter"/>
</Grid.Resources>


<ListBox>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Name="TitleText">
                <Run Foreground="{Binding Type, Converter={StaticResource ColorConverter}}" Text="&#x20b9;" />
            </TextBlock>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

当我运行代码时,没有错误,但是颜色不会改变。

前景使用画笔,而不是颜色。试试这个:

<Run Text="...">
    <Run.Foreground>
        <SolidColorBrush Color="{Binding Type, Converter={StaticResource ColorConverter}}"/>
    </Run.Foreground>
</Run>


它可以工作!!。。你为我节省了很多时间。。!!非常感谢你!!Wpf里满是可爱的小陷阱。
<Run Text="...">
    <Run.Foreground>
        <SolidColorBrush Color="{Binding Type, Converter={StaticResource ColorConverter}}"/>
    </Run.Foreground>
</Run>