0

InvalidOperationException when setting opacity

Anonymous 5 years ago 0
This discussion was imported from CodePlex

keegean wrote at 2011-10-27 01:34:

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.
  Source=WindowsBase
  StackTrace:
       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)
  InnerException:

 

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.


objo wrote at 2011-10-27 08:59:

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


keegean wrote at 2011-10-29 14:54:

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.