I have a large and long running WPF solution currently running in VS 2017. When I migrated from VS 2015, I saw an unusual designer error where instead of showing the design time values from binding to the VM, it would show the property names for nullable properties (e.g., "SomeViewModel.ADoubleNullable" for a double? property) and the default values of the data types for the design time values and not the ones set on the object.
If I switch back to VS 2015 I don't see the issue. Here is what is interesting: if I create a new WPF project in the same solution from scratch with the same settings (4.6.1 with all the defaults), with the same dummy data model and same window, I don't see the problem! And of course, it works at run time just fine.
Here is my VM:
public class DataModel
{
public double NormalDouble { get; set; } = 1;
public double? NullableDouble { get; set; } = 2;
public Child Child { get; set; } = new Child();
}
public class Child
{
public double NormalDouble { get; set; } = 1;
public double? NullableDouble { get; set; } = 2;
}
Here is the View:
<StackPanel d:DataContext="{d:DesignInstance local:DataModel, IsDesignTimeCreatable=True}">
<StackPanel>
<TextBox Text="{Binding NormalDouble}"/>
<TextBox Text="{Binding NullableDouble}"/>
<TextBox Text="{Binding Child.NormalDouble}"/>
<TextBox Text="{Binding Child.NullableDouble}"/>
</StackPanel>
</StackPanel>
I would expect to see "1,2,1,2" and this is the case in a new WPF project. But in my old project, I see "0, NullableDouble, 0, ChildDataModel.NullableDouble".
Anyone seen anything like this or have suggestions on how to troubleshoot? I have tried dropping the IsDesignTimeCreatable attribute, different computers, and deleting the ".vs" folder. I have seen this issue since the first VS 2017 RC until the recent 15.2 (26430.4).