public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null && value.GetType() == typeof(TextBlock)) { var dataContext = ((TextBlock)value).DataContext; if (dataContext != null && dataContext.GetType() == typeof(Stock)) { return(StockUtil.GetStockForgroundColor((Stock)dataContext)); } } return(null); }