Quantcast
Channel: MVVM Light Toolkit
Viewing all 1826 articles
Browse latest View live

Created Unassigned: iOS - bindings does not work [7670]

$
0
0
I have downloaded latest sources and tried to run sample project (Flower) on iOS. App launches fine, but it crashes on following code:

AddCommentViewController, line 28

_commentBinding = this.SetBinding( () => CommentText.Text).UpdateSourceTrigger("Changed");

with "Event not found: changed" message

Edited Unassigned: iOS - bindings do not work on device [7670]

$
0
0
I have downloaded latest sources and tried to run sample project (Flower) on iOS. App launches fine, but it crashes on following code:

AddCommentViewController, line 28

_commentBinding = this.SetBinding( () => CommentText.Text).UpdateSourceTrigger("Changed");

with "Event not found: changed" message.

Interesting is, that it works in Simulator but not on device.

New Post: getting Locator error at run time when trying to use DataTemplate

$
0
0
Hello,

I seemed to be getting jammed up trying to reference a command in my view model from a data template in another file. I've tried following the examples here and here (as well as others), but the results is always the same. I'm getting a run time error of "{"Cannot find resource named 'Locator'. Resource names are case sensitive."}".

For what it's worth, my DataTemplate file looks like this:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
                    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
    <DataTemplate x:Key="DockPanelHeaderDataTemplate">
        <StackPanel Orientation="Horizontal">
            <Image Source="/Images/Add_16x16.png">
                <Image.RenderTransform>
                    <RotateTransform x:Name="AnimatedRotateTransform" CenterX="8" CenterY="8" />
                </Image.RenderTransform>
                <Image.Triggers>
                    <EventTrigger RoutedEvent="Image.MouseEnter">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:.5"
                                                 From="0"
                                                 Storyboard.TargetProperty="RenderTransform.Angle"
                                                 To="45" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Image.MouseLeave">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:.5"
                                                 From="45"
                                                 Storyboard.TargetProperty="RenderTransform.Angle"
                                                 To="0" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Image.Triggers>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Image.MouseEnter">
                        <command:EventToCommand Command="{Binding MainWindow.FooCommand, Source={StaticResource Locator}}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Image>
            <TextBlock Margin="10,0,0,0" Text="{Binding}" />
        </StackPanel>
    </DataTemplate>
</ResourceDictionary>
My viewmodel:
using System.Windows;
using GalaSoft.MvvmLight.Command;
using ViewModelBase = GalaSoft.MvvmLight.ViewModelBase;
using IMessageBoxService = DevExpress.Mvvm.IMessageBoxService;

namespace ESPDistributionDemoProgram.ViewModel
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IMessageBoxService messageBoxService)
        {
            _messageBoxService = messageBoxService;
        }

        private RelayCommand _fooCommand;

        public RelayCommand FooCommand
        {
            get
            {
                return _fooCommand
                       ?? (_fooCommand = new RelayCommand(Foo));
            }
        }

        private void Foo()
        {
            _messageBoxService.Show("This is a test.  Should get fired from DataTemplate", "Success!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
        }

        private readonly IMessageBoxService _messageBoxService;
    }
}
My view:
<Window x:Class="ESPDistributionDemoProgram.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
        xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:ignore="http://www.ignore.com"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:views="clr-namespace:ESPDistributionDemoProgram.Views"
        Title="Distribution Modeller"
        Icon="Images/robot1.ico"
        WindowState="Maximized"
        d:DesignHeight="1394"
        d:DesignWidth="1460"
        dx:ThemeManager.ThemeName="LightGray"
        mc:Ignorable="d ignore">
    <Window.DataContext>
        <Binding x:Name="This"
                 Path="MainWindow"
                 Source="{StaticResource Locator}" />
    </Window.DataContext>
    <dx:BackgroundPanel>
        <Grid>
            <dxe:FlyoutControl Content="{Binding Path=PlacementTarget.Tag,
                                                 RelativeSource={RelativeSource Self}}"
                               PlacementTarget="{Binding ElementName=HxINfoPanel}"
                               Style="{StaticResource CustomFlyoutControlStyle}" />
            <dxdo:DockLayoutManager FloatingMode="Desktop">
                <dxdo:LayoutGroup>
                    <dxdo:LayoutGroup Orientation="Vertical">
                        <dxdo:LayoutPanel x:Name="HxINfoPanel"
                                          AllowClose="False"
                                          AllowMinimize="True"
                                          Caption="Historical Information"
                                          CaptionTemplate="{StaticResource DockPanelHeaderDataTemplate}">
                            <views:HistoricalDataView VerticalAlignment="Top" />
                        </dxdo:LayoutPanel>

                        <dxdo:LayoutPanel AllowClose="False"
                                          AllowMinimize="True"
                                          Caption="Distribution Information"
                                          CaptionTemplate="{StaticResource DockPanelHeaderDataTemplate}">
                            <views:DistributionView VerticalAlignment="Top" />
                        </dxdo:LayoutPanel>
                    </dxdo:LayoutGroup>

                    <dxdo:LayoutPanel AllowClose="False"
                                      AllowMinimize="True"
                                      Caption="Simulation Information"
                                      CaptionTemplate="{StaticResource DockPanelHeaderDataTemplate}">
                        <views:SimulationView />
                    </dxdo:LayoutPanel>
                </dxdo:LayoutGroup>
            </dxdo:DockLayoutManager>

        </Grid>
    </dx:BackgroundPanel>




</Window>
and my ViewModelLocator:

using DevExpress.Xpf.Core;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;

namespace ESPDistributionDemoProgram.ViewModel
{
    /// <summary>
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class ViewModelLocator
    {
        static ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            SimpleIoc.Default.Register(() => new MainViewModel(new DXMessageBoxService()));
            SimpleIoc.Default.Register<DistributionViewModel>();
            SimpleIoc.Default.Register(()=> new HistoricalDataViewModel(new DXMessageBoxService()));
            SimpleIoc.Default.Register<SimulationViewModel>();

        }

        public HistoricalDataViewModel HistoricalData
        {
            get { return ServiceLocator.Current.GetInstance<HistoricalDataViewModel>(); }
        }

        public DistributionViewModel Distribution
        {
            get { return ServiceLocator.Current.GetInstance<DistributionViewModel>(); }
        }

        public SimulationViewModel Simulation
        {
            get { return ServiceLocator.Current.GetInstance<SimulationViewModel>(); }
        }

        public MainViewModel MainWindow
        {
            get { return ServiceLocator.Current.GetInstance<MainViewModel>(); }
        }

   
        /// <summary>
        /// Cleans up all the resources.
        /// </summary>
        public static void Cleanup()
        {
        }
    }
}
I've narrowed down the issue to be specifically in my DataTemplate on this line:
<command:EventToCommand Command="{Binding MainWindow.FooCommand, Source={StaticResource Locator}}" />
The Intellisense works, with I type that line...so Visual Studio knows that the Locator exists, but not the compiler. I'm hoping it's something simple that I'm over looking, but I just can't seem to put my finger on it.

Any help you can provide is greatly appreciated.

Thanks in advance

New Post: Dependency injection inside the background task

$
0
0
Hi,

I use MVVM Light Toolkit and I would like to also use dependency injection inside the background task (Windows Runtime Component). Is there any option how to achieve that?

Thank you,
Jakub

Created Unassigned: Exception in IsInDesignModeNet() in WP8 app [7671]

$
0
0
Just a minor issue, when using the PCL version of MvvmLight 5.0.2.0 in WP8 app, the ViewModelBase.IsInDesignModeStatic getter throws inner ArgumentNullException. For people with OCD, that don't like Exception logs in the Output windows this could be an issue :)

Problem is in ViewModelBase.cs, line 207 and it can be fixed like this:
```
// now
var dmp = dm.GetTypeInfo().GetDeclaredField("IsInDesignModeProperty").GetValue(null);

// fixed
if (dm == null) return false;
var dmp = dm.GetTypeInfo().GetDeclaredField("IsInDesignModeProperty").GetValue(null);
```

This is probably not the only place where similar exception could happen in this file. It's also better performance-wise to handle these errors manually and not using one big try/catch statement.

Created Unassigned: package installation error msg in v5.0.2 and framework 4 [7672]

$
0
0
Hi,

After succesful install of v5.0.2 on vs2012, if creating a wpf4 project the following error appears:
Package installation error
Could not add all required packages to project.
The following package failed to install
CommonServiceLocator1.3 you are trying to install this package into a project that targets framework 4, but the target does not contain any assembly references that are competable with that framework.

See attached email for full message.

Edited Unassigned: package installation error msg in v5.0.2 and framework 4 [7672]

$
0
0
Hi,

After succesful install of v5.0.2 on vs2012, if creating a wpf4 project the following error appears:
Package installation error
Could not add all required packages to project.
The following package failed to install
CommonServiceLocator1.3 you are trying to install this package into a project that targets framework 4, but the target does not contain any assembly references that are competable with that framework.

See attached image for full message.
Does it mean the v5.0.2 supports only framework 4.5 ?

Commented Unassigned: package installation error msg in v5.0.2 and framework 4 [7672]

$
0
0
Hi,

After succesful install of v5.0.2 on vs2012, if creating a wpf4 project the following error appears:
Package installation error
Could not add all required packages to project.
The following package failed to install
CommonServiceLocator1.3 you are trying to install this package into a project that targets framework 4, but the target does not contain any assembly references that are competable with that framework.

See attached image for full message.
Does it mean the v5.0.2 supports only framework 4.5 ?

Comments: Hi, Do I understand correctly that you are creating the WPF4 project using the installed project template (File, New, Project, MVVM Light (WPF4))? If so, I just tried here and it worked fine. To be clear, CommonServiceLocator V1.3 is supported on WPF 4 projects (but not on WPF 3.5). Can you make sure that you have the latest Nuget version? Thanks Laurent

Edited Issue: package installation error msg in v5.0.2 and framework 4 [7672]

$
0
0
Hi,

After succesful install of v5.0.2 on vs2012, if creating a wpf4 project the following error appears:
Package installation error
Could not add all required packages to project.
The following package failed to install
CommonServiceLocator1.3 you are trying to install this package into a project that targets framework 4, but the target does not contain any assembly references that are competable with that framework.

See attached image for full message.
Does it mean the v5.0.2 supports only framework 4.5 ?

Commented Issue: package installation error msg in v5.0.2 and framework 4 [7672]

$
0
0
Hi,

After succesful install of v5.0.2 on vs2012, if creating a wpf4 project the following error appears:
Package installation error
Could not add all required packages to project.
The following package failed to install
CommonServiceLocator1.3 you are trying to install this package into a project that targets framework 4, but the target does not contain any assembly references that are competable with that framework.

See attached image for full message.
Does it mean the v5.0.2 supports only framework 4.5 ?

Comments: Hi, Thanks for your fast reply. This problem only occur at my work PC. At home this work just fine. My work PC has no direct internet access, so I've downloaded the VSIX file (VS2012) on another PC, and brought it to that work PC on some CD / DOK. "Do I understand correctly that you are creating the WPF4 project using the installed project template (File, New, Project, MVVM Light (WPF4))?" - That is correct. I'm unable to update the Nuget, unless there is some way for me to download redest version (offline standalone EXE that does not require me direct internet access). Do I need to manually install the "CommonServiceLocator V1.3" for this to work properly ? regards, Idan

Created Unassigned: Android: Binding on a dynamically generated view [7673]

$
0
0
Could I use the current implementation of the binding in the MVVM light toolkit for the android platform to make binding on a on a dynamically generated views ?

Commented Unassigned: Android: Binding on a dynamically generated view [7673]

$
0
0
Could I use the current implementation of the binding in the MVVM light toolkit for the android platform to make binding on a on a dynamically generated views ?
Comments: Hi, Closing this as it is not an issue. Can I ask you to open a Discussion (using the Discussions tab above) to start a thread about this? Thanks Laurent

Closed Unassigned: Android: Binding on a dynamically generated view [7673]

$
0
0
Could I use the current implementation of the binding in the MVVM light toolkit for the android platform to make binding on a on a dynamically generated views ?

Edited Unassigned: Android: Binding on a dynamically generated view [7673]

$
0
0
Could I use the current implementation of the binding in the MVVM light toolkit for the android platform to make binding on a on a dynamically generated views ?

New Post: Android: Binding on a dynamically generated view

$
0
0
Could I use the current implementation of the binding in the MVVM light toolkit for the android platform to make binding on a on a dynamically generated views ?

Created Unassigned: DialogService throws in Xamarin Android [7674]

$
0
0
The DialogService is working fine on iOS and Windows Phone, but it throws in Android.

To reproduce the bug:
Create a new Shared Project (Blank App Xamarin Forms)
Right click solution and add MVVM Light Libraries only on all three project
Uncheck Fast Deploy in Android project properties
Add in App.cs (in shared project) at the beginning of GetMainPage()

```
var srv = new DialogService();
srv.ShowMessage("test", "test");
```

Run Windows Phone, it's fine

Run Android it throws with this exception:

```
{Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00084] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896
at Android.Runtime.JNIEnv.FinishCreateInstance (IntPtr instance, IntPtr jclass, IntPtr constructorId, Android.Runtime.JValue[] constructorParameters) [0x0000b] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:288
at Android.App.AlertDialog+Builder..ctor (Android.Content.Context context) [0x000ef] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.App.AlertDialog.cs:73
at GalaSoft.MvvmLight.Views.DialogService.CreateBuilder (System.String message, System.String title, System.String buttonConfirmText, System.String buttonCancelText, System.Action afterHideCallback, System.Action`1 afterHideCallbackWithResponse, System.Action`1 afterHideInternal) [0x00022] in c:\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Platform (Android)\Views\DialogService.cs:222
at GalaSoft.MvvmLight.Views.DialogService.ShowMessage (System.String message, System.String title) [0x00006] in c:\MvvmLight\Source\GalaSoft.MvvmLight\GalaSoft.MvvmLight.Platform (Android)\Views\DialogService.cs:103
at AppT.App.GetMainPage () [0x00008] in c:\DevTests\AppT\AppT\AppT\App.cs:18
--- End of managed exception stack trace ---
java.lang.NullPointerException
at android.app.AlertDialog.resolveDialogTheme(AlertDialog.java:143)
at android.app.AlertDialog$Builder.<init>(AlertDialog.java:360)
at appt.droid.MainActivity.n_onCreate(Native Method)
at appt.droid.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
}
```




Created Unassigned: Xamarin Evolve demo NavigationService & nuget is different v5.0.2 [7675]

$
0
0
I tried to reproduce your Xamarin Evolve demo and I'm facing an issue with the NavigationService.

Xamarin Evolve Configure signature
```
public void Configure(string pageKey, Type pageType)
```

GalaSoft.MvvmLight.Platform (Android) Configure signature
```
public void Configure(string key, Type activityType)
```

GalaSoft.MvvmLight.Platform (iOS)
```
public void Configure(string key, Type controllerType)
```

GalaSoft.MvvmLight.Platform (WPSL81) Configure signature
```
public void Configure(string key, Uri targetUri)
```

Do you think it would be possible to add the same signature on the WPSL81 version?

Edited Unassigned: Xamarin Evolve demo NavigationService & nuget is different v5.0.2 [7675]

$
0
0
I tried to reproduce your Xamarin Evolve demo and I'm facing an issue with the NavigationService.

__Configure method problem:__

Xamarin Evolve Configure signature
```
public void Configure(string pageKey, Type pageType)
```

GalaSoft.MvvmLight.Platform (Android) Configure signature
```
public void Configure(string key, Type activityType)
```

GalaSoft.MvvmLight.Platform (iOS)
```
public void Configure(string key, Type controllerType)
```

GalaSoft.MvvmLight.Platform (WPSL81) Configure signature
```
public void Configure(string key, Uri targetUri)
```

Do you think it would be possible to add the same signature on the WPSL81 version?

__Initiliaze method problem__

Xamarin Evolve has an Initiliaze methods for all three platforms.
```
public void Initialize(NavigationPage navigation)
```

There is only one specific for iOS
```
public void Initialize(UINavigationController navigation)
```

Edited Unassigned: Xamarin Evolve demo NavigationService & nuget v5.0.2 is different [7675]

$
0
0
I tried to reproduce your Xamarin Evolve demo and I'm facing an issue with the NavigationService.

__Configure method problem:__

Xamarin Evolve Configure signature
```
public void Configure(string pageKey, Type pageType)
```

GalaSoft.MvvmLight.Platform (Android) Configure signature
```
public void Configure(string key, Type activityType)
```

GalaSoft.MvvmLight.Platform (iOS)
```
public void Configure(string key, Type controllerType)
```

GalaSoft.MvvmLight.Platform (WPSL81) Configure signature
```
public void Configure(string key, Uri targetUri)
```

Do you think it would be possible to add the same signature on the WPSL81 version?

__Initiliaze method problem__

Xamarin Evolve has an Initiliaze methods for all three platforms.
```
public void Initialize(NavigationPage navigation)
```

There is only one specific for iOS
```
public void Initialize(UINavigationController navigation)
```

Commented Unassigned: Xamarin Evolve demo NavigationService & nuget v5.0.2 is different [7675]

$
0
0
I tried to reproduce your Xamarin Evolve demo and I'm facing an issue with the NavigationService.

__Configure method problem:__

Xamarin Evolve Configure signature
```
public void Configure(string pageKey, Type pageType)
```

GalaSoft.MvvmLight.Platform (Android) Configure signature
```
public void Configure(string key, Type activityType)
```

GalaSoft.MvvmLight.Platform (iOS)
```
public void Configure(string key, Type controllerType)
```

GalaSoft.MvvmLight.Platform (WPSL81) Configure signature
```
public void Configure(string key, Uri targetUri)
```

Do you think it would be possible to add the same signature on the WPSL81 version?

__Initiliaze method problem__

Xamarin Evolve has an Initiliaze methods for all three platforms.
```
public void Initialize(NavigationPage navigation)
```

There is only one specific for iOS
```
public void Initialize(UINavigationController navigation)
```
Comments: Hi, The Initialize and the Configure methods are platform-specific. They need to be different because of differences in the way that the navigation works on all these platforms. Can you explain what you mean? Thanks Laurent
Viewing all 1826 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>