Я использую TryFindResource API для получения объекта кисти. но возвращенный объект не имеет доступа к вызывающему потоку - почему?
Мой код:
public static Brush GetErrorBrush()
{
object resValue = Application.Current.TryFindResource("Colors_Error_SCBrush");
if(resValue!=null && resValue is DependencyObject)
{
if(!(resValue as DependencyObject).CheckAccess())
{
//If we dont do this, while assiging the value to Calling API, it fails with exception "Must create DependencySource on same Thread as the DependencyObject."
resValue = Brushes.Red;
}
}
return resValue != null ? (Brush)resValue : Brushes.DarkRed;
}
Кроме того, как я могу найти, кто является родителем этого объекта зависимости - какому потоку он принадлежит?
Ссылка нить .
Спасибо
RDV