These are chat archives for ButchersBoy/Dragablz

26th
Feb 2016
Shawn Anderson
@shawnmanderson
Feb 26 2016 15:11

I made some changes recently so that our app is loading a lot of tabs at startup - these are heavy operations, UI blocking, etc. This has caused me to start getting a strange exception:

System.InvalidCastException: Specified cast is not valid.
at Dragablz.Converters.ShowDefaultCloseButtonConverter.Convert(Object[] values, Type targetType, Object parameter, CultureInfo culture) in C:\projects\dragablz\Dragablz\Converters\ShowDefaultCloseButtonConverter.cs:line 22

I dug into it, and found that occasionally (not always?) the values will contain DependencyProperty.UnsetValue. Did some research as to what would cause that, and nothing came up as the silver bullet. Watching my binding errors in Output window clearly showed the problem:

System.Windows.Data Warning: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Dragablz.TabablzControl', AncestorLevel='1''. BindingExpression:Path=ShowDefaultCloseButton; DataItem=null; target element is 'Button' (Name=''); target property is 'Visibility' (type 'Visibility')
System.Windows.Data Warning: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Dragablz.TabablzControl', AncestorLevel='1''. BindingExpression:Path=FixedHeaderCount; DataItem=null; target element is 'Button' (Name=''); target property is 'Visibility' (type 'Visibility')

Any ideas on how this could be resolved on my side? If not - would there be concerns with adding some type checking to the Convert method to handle UnsetValue or do you want that to Exception? Thanks!

James Willock
@ButchersBoy
Feb 26 2016 15:32
@shawnmanderson yeah...probably make the converters bit safer...can you raise a PR for that one and I can review it?