Невозможно привести объект типа 'MS.Internal.NamedObject' к BitmapImage

Я создаю приложение WPF, в котором я получаю сообщение об ошибке

Невозможно привести объект типа «MS.Internal.NamedObject» к типу «System.Windows.Media.Imaging.BitmapImage».

Код XAML:

<DataGridTemplateColumn ,Header="Active" Width="60">
<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
       <Button>
            <Button.Content>
                <MultiBinding Converter="{StaticResource myImageConverter}"
                              ConverterParameter="Active">
                    <Binding Path="IsClosed"/>
                    <Binding Path="IsChecked"/>
                    <Binding Path="IsActive"/>
                    <Binding Path="TickImage"/>
                    <Binding Path="CrossImage"/>
                </MultiBinding>
            </Button.Content>
        </Button>
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>

C # конвертер код:

public class ImageConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        bool isClosed = (bool)values[0];
        bool isChecked = (bool)values[1];
        bool isActive = (bool)values[2];
        Image img = new Image();

        switch ((string)parameter)
        {
            case "Active":
                if (isClosed == true && isChecked == true)
                {
                    if (isActive == true)
                    {
                        img.Source = (BitmapImage)values[3];
                        img.Stretch = Stretch.Fill;
                    }
                    else
                    {
                        img.Source = (BitmapImage)values[4];
                        img.Stretch = Stretch.Fill;
                    }
                }
                break;
        }

        return img;
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

TickImage и CrossImage являются свойствами класса ViewModel. Они инициализируются в конструкторе ViewModel, как показано ниже.

TickImage = new BitmapImage(new Uri("K:\\projects\\ContentSets\\Ownership\\SOMA\\Staging\\SOMA\\Images\\icon_tick.gif", UriKind.Absolute));
CrossImage = new BitmapImage(new Uri("K:\\projects\\ContentSets\\Ownership\\SOMA\\Staging\\SOMA\\Images\\icon_cross.gif", UriKind.Absolute));
TickImage.Freeze();
CrossImage.Freeze();

IsClosed, IsChecked и IsActive являются свойствами класса DataObject.

Ошибка возникает в 1-й строке условияif (isActive == true)

Я также попробовал следующий код XAML:

<Button.Content>
    <Image>
        <Image.Source>
            <MultiBinding Converter="{StaticResource myImageConverter}"
                  ConverterParameter="Active">
                <Binding Path="IsClosed"/>
                <Binding Path="IsChecked"/>
                <Binding Path="IsActive"/>
                <Binding Path="TickImage"/>
                <Binding Path="CrossImage"/>
            </MultiBinding>
        </Image.Source> 
    </Image>
</Button.Content>

TickImage и CrossImage являются простыми строками в ViewModel и с необходимыми изменениями в конвертере та же ошибка выдается следующим образом

Невозможно привести объект типа «MS.Internal.NamedObject» к типу «System.String».

Ответы на вопрос(1)

Ваш ответ на вопрос