MaterialDesignInXamlToolkit
MaterialDesignInXamlToolkit copied to clipboard
DialogHost: XamlObjectWriterException - Unresolved reference 'ContentCoverBorder'
Bug explanation
When running a Window with nothing else but a DialogHost
, following exception gets thrown:
System.Xaml.XamlObjectWriterException in System.Xaml.dll
Additional text: Unresolved reference 'ContentCoverBorder
.
It has something to do with this PR: https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/commit/bfe348fed9334ea36eebe97f0897ef01c96afb15
When I revert this change, the issue goes away but the binding error shows up again.
Version
5.0.0
Additional context:
Above sources seem to indicate that the use of x:Reference
is discouraged or even prohibited?
I am experiencing the same issue with my app when I try to debug it.
I have attempted to reproduce the issue on a new project but the problem does not occur.
@MichelMichels @alexachso Can any of you provide a small sample that reproduces this? I am unable to reproduce it in a simple WPF app with a Window
including just a DialogHost
in it. I have tried with an empty DialogHost
and also with actual content, but it works in both cases for me.
I am using the latest code (i.e. project reference rather than nuget package). I also tried with the official nuget packages, and still cannot repro the issue.
HI @nicolaihenriksen, I cannot reproduce either. I remember seeing it and then I commented on this issue on 29th of April. If I checkout the commits I did that day of my app and run the app, the binding failure is no longer present. Maybe it is worth mentioning that I run Visual Studio preview. Since I checkout the exact commit that I remember I had the binding failure, the problem should reproduce, but the only thing different from then and now is that since then I updated the visual studio preview version. I don't remember on which version on Visual studio preview I was on 29th of April. :( I'll keep an eye on this, and if I re-encounter it I'll let you know.
@nicolaihenriksen @alexachso this could be the answer. I also run the Microsoft Visual Studio preview edition. I'll update to latest version and check if the issue still occurs.
Hi @MichelMichels do you still see this binding failure today? If so, maybe it is worth noting the version of you Visual studio preview you are on before updating it :)
@alexachso sorry, I saw your comment too late. I've already updated my Visual Studio.
But even after updating, I see following behavior:
- Non-preview version: no exception
- Preview version:
System.Xaml.XamlObjectWriterException
The demo I'm running uses following xaml in MainWindow
:
<Window
x:Class="MDIX.TestApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MDIX.TestApp"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="800"
Height="450"
Style="{StaticResource MaterialDesignWindow}"
mc:Ignorable="d">
<Grid>
<materialDesign:DialogHost />
</Grid>
</Window>
So, the problem seems localized entirely in the preview version.
Ok, I reproduced it.
- New WPF project (basic)
- Installed the MaterialDesignThemes nugget Version 5.0.0.
- Added exact same Window as @MichelMichels showed in the comment above
- (Forgot I did this! Probably on the 29th of April I enabled the "Enable Just My Code" option in Debugging->General). Enabling this ceased to Throw the exception when I was debugging. Now I disabled it, And sure enough the exception is still there:
Here is a zip file with a basic project that does it: MDIXDialogHostTest.zip
So do not forget, in order to have this exception appear, the "System.Xaml.XamlObjectWriterException" option must be enabled in the Exception Setting and also the option "Enable Just My Code" must be disabled.
I also tested with MDIX version 5.0.1-ci662 and it does the same. The version of the VIsual Studio preview I am using now is: Version 17.11.0 Preview 2.0
@alexachso @MichelMichels Awesome work guys! I will try to reproduce it with this info, and see if I can find some sort of fix that does not reintroduce the binding error.
@alexachso @MichelMichels I can now reproduce the issue 👍 Now comes the tough part, finding a valid solution 😄
It is strange that it only occurs in the preview version. Could it be that preview version is running a newer runtime?
@MichelMichels I am seeing some really weird things happening. I can repro the issue, then I change one small thing and the issue is gone. Then I change it back and the issue is still gone. Sometimes if I do a full clean (´git clean -xdf`) I can then reproduce it again, but not every time. That makes it rather difficult to know when/if you have a working fix for it...
I have seen it in both the preview and the non-preview versions, but not consistently.
@MichelMichels As it stands right now (on my PC), simply reverting bfe348fed9334ea36eebe97f0897ef01c96afb15 ensures the exception is not thrown, but it does not re-introduce the binding errors that was the original issue. Very confusing...