MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.34k stars 2.44k forks source link

Getting a red line across window when Document is not active for Avalon Dock #2709

Closed Nfactor26 closed 8 years ago

Nfactor26 commented 8 years ago

What steps will reproduce this issue?

Create a metro window and host AvalonDock inside it.

<MetroWindow>
  <avalonDock:DockingManager x:Name="Manager" DocumentsSource="{Binding Items}" AnchorablesSource="{Binding Tools}"
                             ActiveContent="{Binding ActiveItem, Mode=TwoWay}" LayoutUpdated="OnManagerLayoutUpdated"
                               />
</MetroWindow>   

If one of the document is initially selected and then i select an anchorable tool , there is a red border just above the docking manager , across entire window.

Write problem description here

When inspected with visual studio live navigator, i noticed the following hierarchy: image MetroContentControl has an AdornerDecorator inside its control template , which has a ContentPresenter and a AdornerLayer. This AdornerLayer is having a border inside whose datacontext is set to "ReadOnlyObservableCollection" . This border lights up red as shown below whenever i switch to PropertyGrid or any thing else from my home document tab.

image

### Expected outcome

There should not be any red border across window irrespective of what is selected inside window.

### Environment

punker76 commented 8 years ago

@Nfactor26 Can you create a short sample (on github)? This makes it easier to debug and find the problem. Thx!

Nfactor26 commented 8 years ago

@punker76 Please find the sample project @ https://github.com/Nfactor26/Sample_Repro_Bug_2709_MahApps_Metro/. Sorry for the delay in uploading it.

thoemmi commented 8 years ago

Did you notice the errors in the debug window? I tried your sample code and get these errors during execution:

System.Windows.Data Error: 23 : Cannot convert 'Red_Line_Bug_Demo.Tools.LeftToolOneViewModel' from type 'LeftToolOneViewModel' to type 'Caliburn.Micro.IScreen' for 'en-US' culture with default conversions; consider using Converter property of Binding. NotSupportedException:'System.NotSupportedException: ReferenceConverter cannot convert from Red_Line_Bug_Demo.Tools.LeftToolOneViewModel.
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at System.ComponentModel.ReferenceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)'
System.Windows.Data Error: 7 : ConvertBack cannot convert value 'Red_Line_Bug_Demo.Tools.LeftToolOneViewModel' (type 'LeftToolOneViewModel'). BindingExpression:Path=ActiveItem; DataItem='ShellViewModel' (HashCode=52357250); target element is 'DockingManager' (Name='Manager'); target property is 'ActiveContent' (type 'Object') NotSupportedException:'System.NotSupportedException: ReferenceConverter cannot convert from Red_Line_Bug_Demo.Tools.LeftToolOneViewModel.
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
   at MS.Internal.Data.ObjectTargetConverter.ConvertBack(Object o, Type type, Object parameter, CultureInfo culture)
   at System.Windows.Data.BindingExpression.ConvertBackHelper(IValueConverter converter, Object value, Type sourceType, Object parameter, CultureInfo culture)`
Nfactor26 commented 8 years ago

Yes...I just tried it and noticed if i try to pin/unpin any tools pane , i get an exception in visual studio and the app will stop on trying to continue with the same error details you are getting . Strangely , this never happened with the actual app i am working on and hence did not catch my attention . I changed the binding of active item for avalon dock in xaml to default from two way and that seems to have fixed the issue of red color . However, in the sample app my application is still crashing with a win32 exception saying "The operation completed successfully". I guess i will just ignore this and close this issue as things seems to be fine with my app and the issue is not with the MahApps. Thank you for help guys . Have a nice day !! Cheers !!