【发布时间】:2020-05-29 14:31:45
【问题描述】:
我很困惑,因为在运行时我收到了这个错误: 应用程序调用了为不同线程编组的接口。 (0x8001010E (RPC_E_WRONG_THREAD))'
我有一个 on 对象:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
FontFamily="Segoe MDL2 Assets"
Foreground="{Binding ImageColor, Mode=OneWay}"
Text="{Binding ImageSrc, Mode=OneWay}" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Text="{Binding VisitDescr, Mode=OneWay}" />
</Grid>
在我的班级里
public string ImageSrc
{
get
{
switch (Type)
{
case "c1":
return "\xE8B9";
break;
default:
return "\xE8A5";
break;
}
}
}
public Brush ImageColor
{
get
{
switch (Type)
{
case "c1":
return new SolidColorBrush(Colors.MediumOrchid);
break;
case "c2":
return new SolidColorBrush(Colors.DarkOrchid);
default:
return new SolidColorBrush(Colors.Red);
break;
}
}
}
图像返回时没有任何错误,但颜色会产生错误并且不会更改。
我怎么可能收到编组错误?
【问题讨论】:
标签: wpf data-binding colors runtime-error marshalling