I am working on Windows 8.1 app.
I have a Page
:
<Page d:DataContext="{d:DesignData /SampleData/MySampleData.xaml}"
x:Class="xxx.MyView"
...>
<TextBlock Text="{Binding MyString}"/>
<TextBlock Text="{Binding StartTime}"/>
</Page>
Then I have MySampleData.xaml
:
<local:MyViewModel
...
xmlns:local="using:xxx.ViewModels"
MyString="my text"
StartTime="2014/01/01"/>
In MyViewModel.cs
I have:
public class MyViewModel
{
public string MyString {get; set;}
public DateTime StartTime {get; set;}
}
In designer it displays correctly, but when compiling I get this error in my MySampleData.xaml
:
Cannot assign text value '2014/01/01' into property 'StartTime' of type 'DateTime'
The part for MyString
works perfectly, but the StartTime
does not (it did in Windows 8.0), any idea how to get it working? And why does it try to compile the design data?
Additional Resources
According to this question, the reason is because WinRT does not support TypeConverters
.
I saw this question, it proposes that you create a fake class, but I really want to do it in XAML.
Any ideas?