Two Views: cannot be found in the name scope

Feb 11, 2013 at 12:17 PM
Hi there,

I'm using the mvvmlight toolkit in my application, and the the ViewModelLocator for changing views.
The navigation is done in this way:
In the MainViewModel i have a property called CurrentViewModel
public ViewModelBase CurrentViewModel
readonly static EntryViewModel entryViewModel = new EntryViewModel();
readonly static GoodsReceiptViewModel goodsReceiptViewModel = new GoodsReceiptViewModel();
Which i assign to a ViewModel when i want to change the View:
            switch (sView)
            {
                case "EntryView":
                    this.CurrentViewModel = entryViewModel;
                    entryViewModel.Load();
And My App.xaml:
      <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
            <DataTemplate DataType="{x:Type vm:EntryViewModel}">
                <views:EntryView />
            </DataTemplate>
            <DataTemplate DataType="{x:Type vm:GoodsReceiptViewModel}">
                <views:GoodsReceiptView />
            </DataTemplate>
The problem is that when i change from one view to another the animations start to get "confused" causes an exception when raising a property change.
XAML:
                <Storyboard>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="gridMain">
                        <EasingDoubleKeyFrame KeyTime="0" Value="196.5"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
The exception is the folowing:

"gridMain name cannot be found in the name scope of 'System.Windows.Controls.Grid'"

Is there any other ways for changing views? Does anyone have an ideia why this error occurs?

Thanks,