1
Vote

Error swithing Framework-Layout-ListPrimarySecondaryFormLayout to Metro

description

Hi everyone! We're building our very first WPF/CODE Framework project, and studying the examples (MagazineExample) the following error appeared.
  Message=Cannot set a property on object '#FFFFFFFF' because it is in a read-only state
  Source=WindowsBase
  StackTrace:
       en System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       en System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
       en System.Windows.Media.Brush.set_Opacity(Double value)
       en CODE.Framework.Wpf.Layout.GridPrimarySecondary.SetInternalPrimaryAreaBackgroundBrush() en d:\Projects\CODE.Framework\Framework\DotNet\CODE.Framework\CODE.Framework.Wpf\Layout\GridPrimarySecondary.cs:línea 256
Debugging the CODEFramework source I found this solution, I'm not sure if it's the best choice, but, as I said before, this is my first WPF application.

// GridPrimarySecondary.cs
    private void SetInternalPrimaryAreaBackgroundBrush()
    {
        if (PrimaryAreaBackgroundBrush == null)
        {
            _primaryAreaBackgroundBrush = null;
            return;
        }

        _primaryAreaBackgroundBrush = PrimaryAreaBackgroundBrush.Clone();
        _primaryAreaBackgroundBrush.Opacity = PrimaryAreaBackgroundBrushOpacity;

        if (PrimaryAreaBackgroundBrushLightFactor < .999d || PrimaryAreaBackgroundBrushLightFactor > 1.001d)
        {
            var converter = new LitBrushConverter();
            _primaryAreaBackgroundBrush = converter.Convert(_primaryAreaBackgroundBrush, typeof(Brush), PrimaryAreaBackgroundBrushLightFactor, CultureInfo.InvariantCulture) as Brush;

            if (_primaryAreaBackgroundBrush != null) 
            {
                //LABL - 20150520
                if (_primaryAreaBackgroundBrush.IsFrozen)
                {
                    _primaryAreaBackgroundBrush = _primaryAreaBackgroundBrush.Clone();
                }
                //LABL - 20150520 
                _primaryAreaBackgroundBrush.Opacity = PrimaryAreaBackgroundBrushOpacity;
            }

        }
    }
I hope to be helpful and sorry about my English.

Greets from Buenos Aires, Argentina
Luis.

comments

MarkusEgger wrote Apr 22, 2015 at 7:03 PM

Hello Luis!

It certainly sounds like this isn't what it should do. I will take a look and see what's going on.


Markus