Closed mynameisthing closed 3 years ago
Not sure this is fixable? Override the "global" DataTemplate for System.String will cause a StackOverflowException if that template tries to render a string. I guess this is to be expected. So, If you remove string rendering from that template in the demo it will work but we've essentially broken string rendering:
<!-- data template used for the dialogs example, defines a View for a ViewModel of type DateTime -->
<DataTemplate DataType="{x:Type system:String}">
<StackPanel Margin="16">
<!--<TextBlock Text="England win the World Cup:"/>
<TextBlock Margin="0 8 0 0" Text="{Binding}"/>
<TextBlock Margin="0 8 0 0" Text="You will never see that again."/>-->
<Button
Margin="0 8 0 0"
IsDefault="True"
Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}"
Style="{DynamicResource MaterialDesignFlatButton}"
/>
</StackPanel>
</DataTemplate>
I guess you should not override the string template.
The StackOverflowException is probably caused by the Button which had a string content that needed to be rendered. If you're going to override the string template you it needs to be a simple template like:
<DataTemplate DataType="{x:Type system:String}">
<TextBlock Text="{Binding}" />
</DataTemplate>
But you probably don't want that either because all strings will be affected.
I'd say we close this issue.
Agree. Will close for now unless someone wants to come up with an alternate proposal for this
When I set the DataType for a DialogHost DataTemplate to system:String the application will crash with a Stackoverflow exception. If the DataType is set back to DateTime the issue no longer happens
I found this issue with the MainDemo.WPF project as well. I forked and made the changes in the repository below. https://github.com/akallenbach/MaterialDesignInXamlToolkit
The only Exception text I was able to get was this