InvalidOperationException when setting opacity

Oct 26, 2011 at 11:34 PM

I was trying to change the opacity on a material using the MaterialHelper and it gave me the following exception:

System.InvalidOperationException was unhandled by user code
  Message=Cannot set a property on object '#FFFFFF00' because it is in a read-only state.
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
       at System.Windows.Media.Brush.set_Opacity(Double value)
       at HelixToolkit.MaterialHelper.ChangeOpacity(Material material, Double d)
       at HelixToolkit.MaterialHelper.ChangeOpacity(Material material, Double d)
       at Boids.BoidsViewModel.AddSightBoxes()
       at Boids.BoidsViewModel.set_ShowSight(Boolean value)


I had created a Visual3D object and I set the material on it. I wanted to change the opacity so I used the helper. I passed in the Material of the Visual3D object, that is when I received this exception.

Oct 27, 2011 at 6:59 AM

is your material frozen? can you try changing the material without the helper method from Helix Toolkit?

Oct 29, 2011 at 12:54 PM

I think the material was frozen. I was able to create the material and then modify it with the helper and then set on the object.