I have some viewmodels that I've created in F# and would like to use them for designtime data within Blend but I can't figure out how to get this to work.
I have a simple xaml file with some bindings setup as follows:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RacePacesUI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="RacePacesUI.RacePaceEntryControl"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400"
xmlns:SampleData="using:RacePacesUI.SampleData"
d:DataContext="{d:DesignInstance Type=SampleData:EntrySampleVm, d:IsDesignTimeCreatable=True}">
Where EntrySampleVm is defined as follows:
public class EntrySampleVm : ViewModels.EntryVm
{
public EntrySampleVm()
{
Distance = 26.2;
Time = new TimeSpan(3, 30, 25);
Pace = 4.0;
Speed = 16.5;
}
}
ViewModels.EntryVm is my F# ViewModel class.
Unfortunately I get an error in the designer:
EntrySampleVm does not exist in this namespace
I have a similar looking C# class defined in the same namespace as follows:
public class Test
{
public Test()
{
Distance = 26.2;
Time = new TimeSpan(3, 30, 25);
Pace = 4.0;
Speed = 16.5;
}
public TimeSpan Time { get; set; }
public double Distance { get; set; }
public double Pace { get; set; }
public double Speed { get; set; }
}
If I then set the DataContext as follows:
d:DataContext="{d:DesignInstance Type=SampleData:Test, d:IsDesignTimeCreatable=True}">
Then it all works as expected so it's definitely the case of using the F# ViewModel.
Is there a way of getting this to work? I don't really like the ServiceLocator approach and because I'm creating a Windows Phone project I don't have access to the x:Static and x:Type extensions.
I'm using Blend Version: 12.0.51020.0 Update 4 VS2013: 12.0.31101.00 Update 4
Thanks for any help