开发者

Custom value converter not showing up in expression blend

开发者 https://www.devze.com 2023-03-27 18:49 出处:网络
Eeerrr! This is making me nuts, I have a custom value converter, it takes in an int and returns a SolidColorBrush, it works fine if I open the project in VS and manually type it into the XAML however

Eeerrr! This is making me nuts, I have a custom value converter, it takes in an int and returns a SolidColorBrush, it works fine if I open the project in VS and manually type it into the XAML however Expression blend (4) can't see it, it sees all my other converters just fine. I double checked that the binaries are in the proper folder (we have different build configurations so that can be an issue)... I am stuck - can someone see any issue with this converter code. Now keep in mind the converter is in another assembly but that is how all of them are, I can easily browse to them and use them no problem.

 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
  int conditionType = (int)value;
  switch (conditionType)
  {
    case 1:
      return new SolidColorBrush(Color.FromRgb(241, 230, 155));
    ca开发者_如何学Cse 2:
      return new SolidColorBrush(Color.FromRgb(229, 107, 107));
    case 3:
      return new SolidColorBrush(Color.FromRgb(107, 229, 147));
    case 4:
      return new SolidColorBrush(Color.FromRgb(176, 107, 229));
    case 5:
      return new SolidColorBrush(Color.FromRgb(63, 130, 64));
    case 6:
      return new SolidColorBrush(Color.FromRgb(67, 143, 148));
    case 7:
      return new SolidColorBrush(Color.FromRgb(149, 163, 164));
    default:
      return new SolidColorBrush(Color.FromRgb(149, 163, 164));
  }
  return new SolidColorBrush(Color.FromRgb(241, 230, 155));
}

I would post the whole class namespaces and all however this thing is blowing up on the formatting if I do that - at least in the preview! UHG!

Thanks


The code itself won't prevent Blend from seeing a converter. Does the converter class implement IValueConverter? Does it have a parameterless public constructor? If either of these are missing Blend won't see it. The only other thing I can think of is a missing reference. It pretty much has to be one of those issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消