Using F # ViewModel as Design in Mix

I have some view modes that I created in F # and would like to use them for design time data in Blend, but I cannot figure out how to get this to work.

I have a simple xaml file with some binding settings like this:

<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 like this:

  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 am getting an error in the designer:

EntrySampleVm does not exist in this namespace

      

I have a similar C # class defined in the same namespace:

  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 like this:

d:DataContext="{d:DesignInstance Type=SampleData:Test, d:IsDesignTimeCreatable=True}">

      

Then everything works as expected, so this is definitely a use case for the F # ViewModel.

Is there a way to make this work? I don't really like the ServiceLocator approach, and since I'm creating a Windows Phone project, I don't have access to the x: Static and x: Type extensions.

I am using Blend Version: 12.0.51020.0 Update 4 VS2013: 12.0.31101.00 Update 4

Thanks for any help

+3


source to share





All Articles