Windows phone 8 support

Oct 11, 2012 at 8:42 AM

Are there any plans for providing support for Windows Phone 8 in the nearby future?

Coordinator
Oct 11, 2012 at 4:47 PM

Hi,

Absolutely. In fact it is already built, but I cannot release DLLs publically before the SDK is public.

If you do have access to the WP8 SDK, please send me an email (Laurent at galasoft dot ch)

Thanks

Laurent

Nov 17, 2012 at 4:17 PM

WP 8 is supported in the PCL version here:

https://nuget.org/packages/Portable.MvvmLightLibs

Coordinator
Nov 17, 2012 at 4:23 PM

Note however that I am not supporting the PCL version, at least not yet. The PCL version uses some unofficial DLLs to support the System.Windows.Interactivity namespace.

There is a Windows Phone 8 version available in V4.1 of MVVM Light, see the Download section of this site.

Thanks

Laurent

Nov 17, 2012 at 5:47 PM

The DLLs are the signed, official Microsoft ones, at least for platforms other than NetCore4.5/Metro.

Regards,
Oren

Coordinator
Nov 17, 2012 at 5:49 PM

OK I guess I misunderstood the "unofficial" moniker then. Maybe a better naming would be wise here, I know for sure that "unofficial" is going to frighten some people.

Cheers
Laurent

Dec 13, 2012 at 11:11 AM

Hi all,

today WP8 is fully released, but each time I install Mvvm light toolkit from NuGet, I get the reference to the WP7 assembly.

Do I miss something ? Or is WP8 support not ready ?

regards,

Tim

Dec 13, 2012 at 11:15 AM

Hi Tim,

The Portable.MvvmLightLibs package on NuGet has been tested with WP8, though it does use WP7 assemblies.

WP7 assemblies are fully supported for WP8 apps. MVVM Light doesn't currently have any WP8-specific code, so by releasing it as WP7, it works for both.

If you run into any issues please let me know if you run into any issues -- just make sure you have NuGet 2.1 or later installed first.

Regards,
Oren

Dec 13, 2012 at 11:23 AM

Hi Oren,

in fact, I encounter problem with the EventToCommand. No event is trigerred with this, SelectionChanged event, Loaded event ... nothing.

Is there an incompatibility with WP8 ? It was working with WP7

Best regards

Dec 13, 2012 at 11:45 AM

HI Tim,

Do you have a simple solution you can share with a repro? I can look into it later this afternoon and get a fix for it posted.

Regards,
Oren

Dec 13, 2012 at 12:45 PM
Edited Dec 13, 2012 at 12:47 PM

Not here, tomorrow if needed.

You can reproduce it with an easy sample.

Create a new Windows Phone 8 projet, Nuget for Mvvm Light toolkit, 

On the view, set :

<ListBox ItemsSource="{Binding MyList}">
    <Interactivity:Interaction.Triggers>
        <Interactivity:EventTrigger EventName="SelectionChanged" >
            <Command:EventToCommand Command="{Binding SelectionElementCommand}" PassEventArgsToCommand="True"/>
        </Interactivity:EventTrigger>
    </Interactivity:Interaction.Triggers>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" Margin="10 30 0 0" />
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

with :

xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

On the view-model, you have :

public ICommand SelectionElementCommand { get; set; }

and

SelectionElementCommand = new RelayCommand<SelectionChangedEventArgs>(OnSelectionElement);

with :

private void OnSelectionElement(SelectionChangedEventArgs args)

{
    MessageBox.Show("Here");
}

 

My list is :

 

public const string MyListPropertyName = "MyList";
private List<string> myList = null;
public List<string> MyList
{
    get
    {
        return myList;
    }

    private set
    {
        if (myList == value)
            return;
        myList = value;
        RaisePropertyChanged(MyListPropertyName);
    }
}

 

If it's not enough for you, I can create a sample solution for tomorrow.

Regards,

Tim

Dec 13, 2012 at 12:47 PM

Hi Tim,

I'll take a look, but can you confirm which MVVM Light you're using? Are you using the regular one or the Portable.MvvmLightLibs package? You might need to enable searching for "pre-release" packages due to its dependency on Microsoft.Bcl (which is beta).

Dec 13, 2012 at 1:12 PM

the regular one

Coordinator
Dec 13, 2012 at 1:23 PM

Timor,

If you are using the regular MVVM Light package, you need to use the WP8 DLLs to enable EventToCommand. Unfortunately these are not in Nuget yet. Please download the WP8 DLLs from https://skydrive.live.com/redir?resid=FB0D8F97004979CD!1052

Cheers
Laurent 

Dec 13, 2012 at 1:44 PM

Thanks Laurent,

hope you can publish a NuGet package soon.

Best regards and thanks for the good work :)

Dec 13, 2012 at 3:36 PM

Hi Tim,

Could you please try the portable package and let me know if it works for you? There's additional fixes there beyond what's in the main release too. That portable package supports all platforms with the same binaries.

Thanks,
Oren

Dec 19, 2012 at 8:16 AM

The link have been updated.

Follow

http://sdrv.ms/UUyOfU

to have the new zip "MVVMLight_V4_1_26.zip"

Hope this helps

Benoist LUGNIER

WP8 developer

Jan 17, 2013 at 12:32 PM

I am using the latest version from NuGet, downloaded today

GalaSoft.MvvmLight.Extras.WP8 Version 4.1.26.29756, 

Visual Studio 2012, Windows Phone 8 app

Error 1 The type 'EventToCommand' from assembly 'GalaSoft.MvvmLight.Extras.WP8' is built with an older version of the Blend SDK, and is not supported in a Windows Presentation Framework 8 project. 

I tried with the DLL from http://sdrv.ms/UUyOfU (previous link given above) but it still doesn't work

Thanks

Jan 17, 2013 at 3:06 PM

Hi nitescua,

If you try the Portable.MvvmLightLibs package (the PCL fork), that one includes references to the latest official Blend SDK and Common Service Locator binaries and should resolve the issue for you.

Regards,
Oren

Jan 17, 2013 at 3:07 PM
Edited Jan 17, 2013 at 3:10 PM

Hi Oren,

Are these available by NuGet? how to get them exactly?

I would appreciate if Laurent can give any hints on this. I do not wish to work with a fork version.

Thanks 

Jan 17, 2013 at 3:09 PM

They are on NuGet. I'd recommend uninstalling the regular ones first to prevent dll conflicts, but you can search for "Portable.MvvmLightLibs" in the NuGet search dialog or by using the command line: Install-Package Portable.MvvmLightLibs -Version 4.1.26.1

 

 

Coordinator
Jan 17, 2013 at 4:09 PM

Hi Andrei,

The error you posted is weird. You talk about Windows Phone application but the error mentions "Windows Presentation Framework 8". 

It sounds like you are using the wrong DLLs in your project. Can you make sure that you the error is correct?

Thanks
Laurent 

Jan 17, 2013 at 4:14 PM

I used NuGet to get the package today in a Windows Phone 8 app.

The error appeared as soon as I wanted to use the EventToCommand from the Extras assembly.

 

Extras 
Coordinator
Jan 17, 2013 at 4:29 PM

Hi,

Just tried creating a new Windows Phone 8 application and adding the MVVM Light Libs only package. I was able to add an element and use EventToCommand to link the element's Loaded event to a Command on my page.

Then I created another Windows Phone 8 app and added the MVVM Light package (full). I added the same command to the ViewModel, had to fix a small issue in XAML (will check it out in the next release) and then added the EventToCommand in Blend and bound to the VM's command.

I didn't get any compilation errors.

Do you want to send me your project for me to take a look>

Cheers
Laurent 

Jan 17, 2013 at 4:33 PM

Thank you Laurent.

I haven no idea what's going on. I actually did try by removing and reinstalling but without no luck.

I will do a new project to test in few minutes and let you know.

Thanks again.

Jan 17, 2013 at 5:18 PM

I removed MVVMLight again, deleted the directory in packages folder (it couldnt delete System.Windows.Interactivity, even after VS restart), added MVVMLight by NuGet, everything works now, I'm good

No idea what happened.

Thanks and I am sorry for the trouble, Laurent.

 

Off-topic question: Did SimpleIoc have support before for creating new instances of types something like this:

.Register<IMyInterface, MyInterface>( ()=> { return new MyInterface(); } )

The problem I have is I do not want the view models instances to be reused. The only way I see is to replace SimpleIoC with a different IoC.

Any idea how to do this without using a different IoC?

Another way of asking this is, how are people generally working with view-models, isn't it simpler if view-models exist only as long as the views exists? ViewModels can pass a state (a view-model state object) to one another. Having to clean-up properties to reinitialize the view-model doesn't look right for me. Or maybe my approach is wrong?

 

Feb 9, 2013 at 3:17 PM
@onovotny I'm still getting a similar error with the Portable branch. Looks fine with the regular libs though. (I am on Nuget 2.2)

1-Built a new WP8 App.
2-Installed the latest portable branch from nuget (4.1.27 from feb 8th)
3-Add the namespaces
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=Galasoft.MvvmLight.Platforms.WP75"   
4-Add an event to command
<Rectangle Fill="White"
           Stroke="Black"
           Width="200"
           Height="100">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseEnter">
                        <cmd:EventToCommand Command="{Binding TestCommand, Mode=OneWay}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Rectangle>
Immediately get errors. I also tried it with an older version (4.1.26.1)
Error The tag 'EventToCommand' does not exist in XML namespace 'clr-namespace:GalaSoft.MvvmLight.Command;assembly=Galasoft.MvvmLight.Platforms.WP75'.
Error The type 'EventToCommand' from assembly 'GalaSoft.MvvmLight.Platforms.WP75' is built with an older version of the Blend SDK, and is not supported in a Windows Presentation Framework 8 project.

Blend gives
Unable to cast object of type 'Galasoft.MvvmLight.Command.EventToCommand' to type 'System.Windows.Interactivity.TriggerAction'

Some of the errors come and go but it never seems to build correctly or run.

Posted sample solution here in case I'm doing something wrong.
http://www.filedropper.com/phoneapp1

Any help is appreciated.
Feb 9, 2013 at 4:08 PM
Hi,

I just updated the NuGet package to 4.1.27.1 which contains a fix. The problem was a mis-match between the referenced interactivity.dll in the WP75 dll and the one referenced by the project (wp8).

I've now created a WP8 platform dll that references the correct interactivity.dll.

When you update, you'll have to update the assembly name from WP75 to WP8, but I was able to see it working in your sample project with the fix. When I click down in the white rect, I saw a command called.

Please let me know if that works for you.
Feb 10, 2013 at 2:51 AM
Looks like it is working in VS and Blend. Thanks. Appreciate the quick response.
Apr 5 at 12:53 AM
It seems Install-Package Portable.MvvmLightLibs does not work for a visual C++ project. It just works for C#. Is that right? IF so, when will it be available for C++?

This is the error code:

PM> Install-Package Portable.MvvmLightLibs
Installing 'Portable.MvvmLightLibs 4.3.31.1'.
You are downloading Portable.MvvmLightLibs from Laurent Bugnion (GalaSoft), onovotny, the license agreement to which is available at http://mvvmlight.codeplex.com/license. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Portable.MvvmLightLibs 4.3.31.1'.
Adding 'Portable.MvvmLightLibs 4.3.31.1' to App3.
Uninstalling 'Portable.MvvmLightLibs 4.3.31.1'.
Successfully uninstalled 'Portable.MvvmLightLibs 4.3.31.1'.
Install failed. Rolling back...
Install-Package : Could not install package 'Portable.MvvmLightLibs 4.3.31.1'. You are trying to
install this package into a project that targets 'Native,Version=v0.0', but the package does not
contain any assembly references or content files that are compatible with that framework. For
more information, contact the package author.
At line:1 char:1
  • Install-Package Portable.MvvmLightLibs
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
    • FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPack
      ageCommand
Coordinator
May 11 at 4:30 PM
Hi,

At this point I have no plans to release a C++ version.

Sorry
Laurent