Priyanka
Priyanka

Reputation: 3

The provided DependencyObject is not a context for this Freezable exception when assigning Image control's Source property

I'm getting the exception The provided DependencyObject is not a context for this Freezable, when trying to assign the Source of Image control.

In xaml the image control is created.

    <Image x:Name ="DestinationImage"  Stretch="Fill" RenderOptions.BitmapScalingMode="HighQuality" />

The source is set from code behind.

    public ImageSource DestinationImageSource
    {
        get { return DestinationImage.Source; }
        set
        {
            if (DestinationImage.Source != value)
            {
                OnPropertyChanging("DestinationImageSource");
                DestinationImage.Source = value;
                OnPropertyChanged("DestinationImageSource");
            }
        }
    }

I tried checking whether the control is frozen "DestinationImage.Source.IsFrozen". But the IsFrozen property is false, still the exception comes on assigning the ImageSource.

Upvotes: 0

Views: 39

Answers (0)

Related Questions