(MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity











up vote
0
down vote

favorite












I'm having a problem with binding in MvvmCross and Xamarin Forms. When I'm navigating from my MainViewModel to FileInfoViewModel, I'm getting following error:



(MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity



I have used MvvmCross setup like described here



This is my RootActivity.cs code in Android project:



    [Activity(Label = "XFCubage", Icon = "@mipmap/icon", Theme = "@style/MainTheme",
MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class RootActivity : MvxFormsAppCompatActivity<MvxFormsAndroidSetup<Core.App, App>, Core.App, App>
{
protected override void OnCreate(Bundle savedInstanceState)
{
CrossCurrentActivity.Current.Activity = this;
base.OnCreate(savedInstanceState);
}
}


This is my FileInfoViewModel.cs that I'm navigating from MainViewModel (during navigation, I'm passing object InfoDetail):



namespace XFCubage.Core.ViewModels
{
public class FileInfoViewModel : MvxViewModel<InfoDetail>
{
public ObservableCollection<SideMenuItem> MenuItems { get; set; }
public InfoDetail Detail { get; private set; }
public SideMenuItem SelectedMenuItem { get; set; }
private int _sideMenuWidth;
public int SideMenuWidth
{
get => _sideMenuWidth;
set => SetProperty(ref _sideMenuWidth, value);
}

private IMvxNavigationService _navigationService;

public FileInfoViewModel(IMvxNavigationService navigationService)
{
_navigationService = navigationService;

InitializeSideMenuItems();

CrossDeviceOrientation.Current.OrientationChanged += (sender,
args) =>
{
var orientation = args.Orientation;
SetSideMenuWidth(orientation);
};
}


void SetSideMenuWidth(DeviceOrientations orientation)
{
if (orientation == DeviceOrientations.Landscape ||
orientation == DeviceOrientations.LandscapeFlipped)
SideMenuWidth = 250;
else
SideMenuWidth = 65;
}

public void InitializeSideMenuItems()
{
MenuItems = new ObservableCollection<SideMenuItem>();
MenuItems.Add(new SideMenuItem() { Id = 1, Title = "FILE INFO", ImageSource = ImageSource.FromFile("fileinfo.png"), Selected = true });
MenuItems.Add(new SideMenuItem() { Id = 2, Title = "LOADING ADDRESS", ImageSource = ImageSource.FromFile("loadingaddress.png"), Selected = false });
MenuItems.Add(new SideMenuItem() { Id = 3, Title = "DELIVERY ADDRESS", ImageSource = ImageSource.FromFile("deliveryaddress.png"), Selected = false });
MenuItems.Add(new SideMenuItem() { Id = 4, Title = "QUOTE ADDRESS", ImageSource = ImageSource.FromFile("quoteaddress.png"), Selected = false });
MenuItems.Add(new SideMenuItem() { Id = 5, Title = "BILLING ADDRESS", ImageSource = ImageSource.FromFile("wallet.png"), Selected = false });
MenuItems.Add(new SideMenuItem() { Id = 6, Title = "ROOMS", ImageSource = ImageSource.FromFile("rooms.png"), Selected = false });
MenuItems.Add(new SideMenuItem() { Id = 7, Title = "SUMMARY", ImageSource = ImageSource.FromFile("summary.png"), Selected = false });
SelectedMenuItem = MenuItems[0];
}

public override void Prepare(InfoDetail parameter)
{
Detail = parameter;
}
}
}


This my FileInfoPage.xaml:



<?xml version="1.0" encoding="utf-8" ?>
<views:MvxContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms"
xmlns:components="clr-namespace:XFCubage.Core.Components;assembly=XFCubage.Core"
xmlns:viewModels="clr-namespace:XFCubage.Core.ViewModels;assembly=XFCubage.Core"
x:TypeArguments="viewModels:FileInfoViewModel"
x:Class="XFCubage.Views.FileInfoPage"
BackgroundColor="{StaticResource PageBackgroundColor}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding SideMenuWidth}"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<listview:SfListView ItemsSource="{Binding MenuItems}"
BackgroundColor="{StaticResource TableHeaderBackground}"
ItemSpacing="0,10,0,10"
SelectionMode="Single" SelectionGesture="Tap" SelectedItem="{Binding SelectedMenuItem, Mode=TwoWay}">
<listview:SfListView.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal">
<BoxView WidthRequest="3"/>
<Image Source="{Binding ImageSource}" WidthRequest="24" HeightRequest="24" Margin="10,0,20,0"/>
<Label Text="{Binding Title}" TextColor="{StaticResource TextColor}" VerticalTextAlignment="Center"/>
</StackLayout>
</DataTemplate>
</listview:SfListView.ItemTemplate>
<listview:SfListView.SelectedItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal" BackgroundColor="{StaticResource SelectedItemBackgroundColor}">
<BoxView WidthRequest="3" BackgroundColor="{StaticResource HighlightColor}"/>
<Image Source="{Binding ImageSource}" WidthRequest="24" HeightRequest="24" Margin="10,0,20,0"/>
<Label Text="{Binding Title}" TextColor="{StaticResource TextColor}" VerticalTextAlignment="Center"/>
</StackLayout>
</DataTemplate>
</listview:SfListView.SelectedItemTemplate>
</listview:SfListView>
</Grid>




Problem occures in this line in XAML bindin. I receive an error:



(MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity:



<ColumnDefinition Width="{Binding SideMenuWidth}"/>


When I change this line to:



<ColumnDefinition Width="250"/>


Everything seems to be okay. The stranges thing is that binding for listview (model Detail that I'm passing from MainViewModel to FileInfoViewModel) works.



Can you please help me because I'm confused.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I'm having a problem with binding in MvvmCross and Xamarin Forms. When I'm navigating from my MainViewModel to FileInfoViewModel, I'm getting following error:



    (MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity



    I have used MvvmCross setup like described here



    This is my RootActivity.cs code in Android project:



        [Activity(Label = "XFCubage", Icon = "@mipmap/icon", Theme = "@style/MainTheme",
    MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class RootActivity : MvxFormsAppCompatActivity<MvxFormsAndroidSetup<Core.App, App>, Core.App, App>
    {
    protected override void OnCreate(Bundle savedInstanceState)
    {
    CrossCurrentActivity.Current.Activity = this;
    base.OnCreate(savedInstanceState);
    }
    }


    This is my FileInfoViewModel.cs that I'm navigating from MainViewModel (during navigation, I'm passing object InfoDetail):



    namespace XFCubage.Core.ViewModels
    {
    public class FileInfoViewModel : MvxViewModel<InfoDetail>
    {
    public ObservableCollection<SideMenuItem> MenuItems { get; set; }
    public InfoDetail Detail { get; private set; }
    public SideMenuItem SelectedMenuItem { get; set; }
    private int _sideMenuWidth;
    public int SideMenuWidth
    {
    get => _sideMenuWidth;
    set => SetProperty(ref _sideMenuWidth, value);
    }

    private IMvxNavigationService _navigationService;

    public FileInfoViewModel(IMvxNavigationService navigationService)
    {
    _navigationService = navigationService;

    InitializeSideMenuItems();

    CrossDeviceOrientation.Current.OrientationChanged += (sender,
    args) =>
    {
    var orientation = args.Orientation;
    SetSideMenuWidth(orientation);
    };
    }


    void SetSideMenuWidth(DeviceOrientations orientation)
    {
    if (orientation == DeviceOrientations.Landscape ||
    orientation == DeviceOrientations.LandscapeFlipped)
    SideMenuWidth = 250;
    else
    SideMenuWidth = 65;
    }

    public void InitializeSideMenuItems()
    {
    MenuItems = new ObservableCollection<SideMenuItem>();
    MenuItems.Add(new SideMenuItem() { Id = 1, Title = "FILE INFO", ImageSource = ImageSource.FromFile("fileinfo.png"), Selected = true });
    MenuItems.Add(new SideMenuItem() { Id = 2, Title = "LOADING ADDRESS", ImageSource = ImageSource.FromFile("loadingaddress.png"), Selected = false });
    MenuItems.Add(new SideMenuItem() { Id = 3, Title = "DELIVERY ADDRESS", ImageSource = ImageSource.FromFile("deliveryaddress.png"), Selected = false });
    MenuItems.Add(new SideMenuItem() { Id = 4, Title = "QUOTE ADDRESS", ImageSource = ImageSource.FromFile("quoteaddress.png"), Selected = false });
    MenuItems.Add(new SideMenuItem() { Id = 5, Title = "BILLING ADDRESS", ImageSource = ImageSource.FromFile("wallet.png"), Selected = false });
    MenuItems.Add(new SideMenuItem() { Id = 6, Title = "ROOMS", ImageSource = ImageSource.FromFile("rooms.png"), Selected = false });
    MenuItems.Add(new SideMenuItem() { Id = 7, Title = "SUMMARY", ImageSource = ImageSource.FromFile("summary.png"), Selected = false });
    SelectedMenuItem = MenuItems[0];
    }

    public override void Prepare(InfoDetail parameter)
    {
    Detail = parameter;
    }
    }
    }


    This my FileInfoPage.xaml:



    <?xml version="1.0" encoding="utf-8" ?>
    <views:MvxContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:views="clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms"
    xmlns:components="clr-namespace:XFCubage.Core.Components;assembly=XFCubage.Core"
    xmlns:viewModels="clr-namespace:XFCubage.Core.ViewModels;assembly=XFCubage.Core"
    x:TypeArguments="viewModels:FileInfoViewModel"
    x:Class="XFCubage.Views.FileInfoPage"
    BackgroundColor="{StaticResource PageBackgroundColor}">
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="{Binding SideMenuWidth}"/>
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <listview:SfListView ItemsSource="{Binding MenuItems}"
    BackgroundColor="{StaticResource TableHeaderBackground}"
    ItemSpacing="0,10,0,10"
    SelectionMode="Single" SelectionGesture="Tap" SelectedItem="{Binding SelectedMenuItem, Mode=TwoWay}">
    <listview:SfListView.ItemTemplate>
    <DataTemplate>
    <StackLayout Orientation="Horizontal">
    <BoxView WidthRequest="3"/>
    <Image Source="{Binding ImageSource}" WidthRequest="24" HeightRequest="24" Margin="10,0,20,0"/>
    <Label Text="{Binding Title}" TextColor="{StaticResource TextColor}" VerticalTextAlignment="Center"/>
    </StackLayout>
    </DataTemplate>
    </listview:SfListView.ItemTemplate>
    <listview:SfListView.SelectedItemTemplate>
    <DataTemplate>
    <StackLayout Orientation="Horizontal" BackgroundColor="{StaticResource SelectedItemBackgroundColor}">
    <BoxView WidthRequest="3" BackgroundColor="{StaticResource HighlightColor}"/>
    <Image Source="{Binding ImageSource}" WidthRequest="24" HeightRequest="24" Margin="10,0,20,0"/>
    <Label Text="{Binding Title}" TextColor="{StaticResource TextColor}" VerticalTextAlignment="Center"/>
    </StackLayout>
    </DataTemplate>
    </listview:SfListView.SelectedItemTemplate>
    </listview:SfListView>
    </Grid>




    Problem occures in this line in XAML bindin. I receive an error:



    (MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity:



    <ColumnDefinition Width="{Binding SideMenuWidth}"/>


    When I change this line to:



    <ColumnDefinition Width="250"/>


    Everything seems to be okay. The stranges thing is that binding for listview (model Detail that I'm passing from MainViewModel to FileInfoViewModel) works.



    Can you please help me because I'm confused.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm having a problem with binding in MvvmCross and Xamarin Forms. When I'm navigating from my MainViewModel to FileInfoViewModel, I'm getting following error:



      (MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity



      I have used MvvmCross setup like described here



      This is my RootActivity.cs code in Android project:



          [Activity(Label = "XFCubage", Icon = "@mipmap/icon", Theme = "@style/MainTheme",
      MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
      public class RootActivity : MvxFormsAppCompatActivity<MvxFormsAndroidSetup<Core.App, App>, Core.App, App>
      {
      protected override void OnCreate(Bundle savedInstanceState)
      {
      CrossCurrentActivity.Current.Activity = this;
      base.OnCreate(savedInstanceState);
      }
      }


      This is my FileInfoViewModel.cs that I'm navigating from MainViewModel (during navigation, I'm passing object InfoDetail):



      namespace XFCubage.Core.ViewModels
      {
      public class FileInfoViewModel : MvxViewModel<InfoDetail>
      {
      public ObservableCollection<SideMenuItem> MenuItems { get; set; }
      public InfoDetail Detail { get; private set; }
      public SideMenuItem SelectedMenuItem { get; set; }
      private int _sideMenuWidth;
      public int SideMenuWidth
      {
      get => _sideMenuWidth;
      set => SetProperty(ref _sideMenuWidth, value);
      }

      private IMvxNavigationService _navigationService;

      public FileInfoViewModel(IMvxNavigationService navigationService)
      {
      _navigationService = navigationService;

      InitializeSideMenuItems();

      CrossDeviceOrientation.Current.OrientationChanged += (sender,
      args) =>
      {
      var orientation = args.Orientation;
      SetSideMenuWidth(orientation);
      };
      }


      void SetSideMenuWidth(DeviceOrientations orientation)
      {
      if (orientation == DeviceOrientations.Landscape ||
      orientation == DeviceOrientations.LandscapeFlipped)
      SideMenuWidth = 250;
      else
      SideMenuWidth = 65;
      }

      public void InitializeSideMenuItems()
      {
      MenuItems = new ObservableCollection<SideMenuItem>();
      MenuItems.Add(new SideMenuItem() { Id = 1, Title = "FILE INFO", ImageSource = ImageSource.FromFile("fileinfo.png"), Selected = true });
      MenuItems.Add(new SideMenuItem() { Id = 2, Title = "LOADING ADDRESS", ImageSource = ImageSource.FromFile("loadingaddress.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 3, Title = "DELIVERY ADDRESS", ImageSource = ImageSource.FromFile("deliveryaddress.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 4, Title = "QUOTE ADDRESS", ImageSource = ImageSource.FromFile("quoteaddress.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 5, Title = "BILLING ADDRESS", ImageSource = ImageSource.FromFile("wallet.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 6, Title = "ROOMS", ImageSource = ImageSource.FromFile("rooms.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 7, Title = "SUMMARY", ImageSource = ImageSource.FromFile("summary.png"), Selected = false });
      SelectedMenuItem = MenuItems[0];
      }

      public override void Prepare(InfoDetail parameter)
      {
      Detail = parameter;
      }
      }
      }


      This my FileInfoPage.xaml:



      <?xml version="1.0" encoding="utf-8" ?>
      <views:MvxContentPage
      xmlns="http://xamarin.com/schemas/2014/forms"
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      xmlns:views="clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms"
      xmlns:components="clr-namespace:XFCubage.Core.Components;assembly=XFCubage.Core"
      xmlns:viewModels="clr-namespace:XFCubage.Core.ViewModels;assembly=XFCubage.Core"
      x:TypeArguments="viewModels:FileInfoViewModel"
      x:Class="XFCubage.Views.FileInfoPage"
      BackgroundColor="{StaticResource PageBackgroundColor}">
      <Grid>
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="{Binding SideMenuWidth}"/>
      <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <listview:SfListView ItemsSource="{Binding MenuItems}"
      BackgroundColor="{StaticResource TableHeaderBackground}"
      ItemSpacing="0,10,0,10"
      SelectionMode="Single" SelectionGesture="Tap" SelectedItem="{Binding SelectedMenuItem, Mode=TwoWay}">
      <listview:SfListView.ItemTemplate>
      <DataTemplate>
      <StackLayout Orientation="Horizontal">
      <BoxView WidthRequest="3"/>
      <Image Source="{Binding ImageSource}" WidthRequest="24" HeightRequest="24" Margin="10,0,20,0"/>
      <Label Text="{Binding Title}" TextColor="{StaticResource TextColor}" VerticalTextAlignment="Center"/>
      </StackLayout>
      </DataTemplate>
      </listview:SfListView.ItemTemplate>
      <listview:SfListView.SelectedItemTemplate>
      <DataTemplate>
      <StackLayout Orientation="Horizontal" BackgroundColor="{StaticResource SelectedItemBackgroundColor}">
      <BoxView WidthRequest="3" BackgroundColor="{StaticResource HighlightColor}"/>
      <Image Source="{Binding ImageSource}" WidthRequest="24" HeightRequest="24" Margin="10,0,20,0"/>
      <Label Text="{Binding Title}" TextColor="{StaticResource TextColor}" VerticalTextAlignment="Center"/>
      </StackLayout>
      </DataTemplate>
      </listview:SfListView.SelectedItemTemplate>
      </listview:SfListView>
      </Grid>




      Problem occures in this line in XAML bindin. I receive an error:



      (MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity:



      <ColumnDefinition Width="{Binding SideMenuWidth}"/>


      When I change this line to:



      <ColumnDefinition Width="250"/>


      Everything seems to be okay. The stranges thing is that binding for listview (model Detail that I'm passing from MainViewModel to FileInfoViewModel) works.



      Can you please help me because I'm confused.










      share|improve this question













      I'm having a problem with binding in MvvmCross and Xamarin Forms. When I'm navigating from my MainViewModel to FileInfoViewModel, I'm getting following error:



      (MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity



      I have used MvvmCross setup like described here



      This is my RootActivity.cs code in Android project:



          [Activity(Label = "XFCubage", Icon = "@mipmap/icon", Theme = "@style/MainTheme",
      MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
      public class RootActivity : MvxFormsAppCompatActivity<MvxFormsAndroidSetup<Core.App, App>, Core.App, App>
      {
      protected override void OnCreate(Bundle savedInstanceState)
      {
      CrossCurrentActivity.Current.Activity = this;
      base.OnCreate(savedInstanceState);
      }
      }


      This is my FileInfoViewModel.cs that I'm navigating from MainViewModel (during navigation, I'm passing object InfoDetail):



      namespace XFCubage.Core.ViewModels
      {
      public class FileInfoViewModel : MvxViewModel<InfoDetail>
      {
      public ObservableCollection<SideMenuItem> MenuItems { get; set; }
      public InfoDetail Detail { get; private set; }
      public SideMenuItem SelectedMenuItem { get; set; }
      private int _sideMenuWidth;
      public int SideMenuWidth
      {
      get => _sideMenuWidth;
      set => SetProperty(ref _sideMenuWidth, value);
      }

      private IMvxNavigationService _navigationService;

      public FileInfoViewModel(IMvxNavigationService navigationService)
      {
      _navigationService = navigationService;

      InitializeSideMenuItems();

      CrossDeviceOrientation.Current.OrientationChanged += (sender,
      args) =>
      {
      var orientation = args.Orientation;
      SetSideMenuWidth(orientation);
      };
      }


      void SetSideMenuWidth(DeviceOrientations orientation)
      {
      if (orientation == DeviceOrientations.Landscape ||
      orientation == DeviceOrientations.LandscapeFlipped)
      SideMenuWidth = 250;
      else
      SideMenuWidth = 65;
      }

      public void InitializeSideMenuItems()
      {
      MenuItems = new ObservableCollection<SideMenuItem>();
      MenuItems.Add(new SideMenuItem() { Id = 1, Title = "FILE INFO", ImageSource = ImageSource.FromFile("fileinfo.png"), Selected = true });
      MenuItems.Add(new SideMenuItem() { Id = 2, Title = "LOADING ADDRESS", ImageSource = ImageSource.FromFile("loadingaddress.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 3, Title = "DELIVERY ADDRESS", ImageSource = ImageSource.FromFile("deliveryaddress.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 4, Title = "QUOTE ADDRESS", ImageSource = ImageSource.FromFile("quoteaddress.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 5, Title = "BILLING ADDRESS", ImageSource = ImageSource.FromFile("wallet.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 6, Title = "ROOMS", ImageSource = ImageSource.FromFile("rooms.png"), Selected = false });
      MenuItems.Add(new SideMenuItem() { Id = 7, Title = "SUMMARY", ImageSource = ImageSource.FromFile("summary.png"), Selected = false });
      SelectedMenuItem = MenuItems[0];
      }

      public override void Prepare(InfoDetail parameter)
      {
      Detail = parameter;
      }
      }
      }


      This my FileInfoPage.xaml:



      <?xml version="1.0" encoding="utf-8" ?>
      <views:MvxContentPage
      xmlns="http://xamarin.com/schemas/2014/forms"
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      xmlns:views="clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms"
      xmlns:components="clr-namespace:XFCubage.Core.Components;assembly=XFCubage.Core"
      xmlns:viewModels="clr-namespace:XFCubage.Core.ViewModels;assembly=XFCubage.Core"
      x:TypeArguments="viewModels:FileInfoViewModel"
      x:Class="XFCubage.Views.FileInfoPage"
      BackgroundColor="{StaticResource PageBackgroundColor}">
      <Grid>
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="{Binding SideMenuWidth}"/>
      <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <listview:SfListView ItemsSource="{Binding MenuItems}"
      BackgroundColor="{StaticResource TableHeaderBackground}"
      ItemSpacing="0,10,0,10"
      SelectionMode="Single" SelectionGesture="Tap" SelectedItem="{Binding SelectedMenuItem, Mode=TwoWay}">
      <listview:SfListView.ItemTemplate>
      <DataTemplate>
      <StackLayout Orientation="Horizontal">
      <BoxView WidthRequest="3"/>
      <Image Source="{Binding ImageSource}" WidthRequest="24" HeightRequest="24" Margin="10,0,20,0"/>
      <Label Text="{Binding Title}" TextColor="{StaticResource TextColor}" VerticalTextAlignment="Center"/>
      </StackLayout>
      </DataTemplate>
      </listview:SfListView.ItemTemplate>
      <listview:SfListView.SelectedItemTemplate>
      <DataTemplate>
      <StackLayout Orientation="Horizontal" BackgroundColor="{StaticResource SelectedItemBackgroundColor}">
      <BoxView WidthRequest="3" BackgroundColor="{StaticResource HighlightColor}"/>
      <Image Source="{Binding ImageSource}" WidthRequest="24" HeightRequest="24" Margin="10,0,20,0"/>
      <Label Text="{Binding Title}" TextColor="{StaticResource TextColor}" VerticalTextAlignment="Center"/>
      </StackLayout>
      </DataTemplate>
      </listview:SfListView.SelectedItemTemplate>
      </listview:SfListView>
      </Grid>




      Problem occures in this line in XAML bindin. I receive an error:



      (MvvmCross.Logging.MvxLog) No view model association found for candidate view RootActivity:



      <ColumnDefinition Width="{Binding SideMenuWidth}"/>


      When I change this line to:



      <ColumnDefinition Width="250"/>


      Everything seems to be okay. The stranges thing is that binding for listview (model Detail that I'm passing from MainViewModel to FileInfoViewModel) works.



      Can you please help me because I'm confused.







      data-binding xamarin.forms mvvmcross






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 8:46









      user3569465

      3116




      3116
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          According to your code, I don’t see where you are linking the (data) ViewModel to (UI)FileInfoPagelian, I guess it is the reason you have this error message.



          Usually, I create Xamarin.Form, the UI is in xxx.xaml, connecting Viewmodel in xxx.xaml.cs, like this:



          https://www.c-sharpcorner.com/article/xamarin-forms-create-mvvm-data-binding-application/






          share|improve this answer





















          • With MvvmCross in xaml you put: x:TypeArguments="viewModels:FileInfoViewModel"
            – user3569465
            Nov 13 at 7:58













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222397%2fmvvmcross-logging-mvxlog-no-view-model-association-found-for-candidate-view-ro%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          According to your code, I don’t see where you are linking the (data) ViewModel to (UI)FileInfoPagelian, I guess it is the reason you have this error message.



          Usually, I create Xamarin.Form, the UI is in xxx.xaml, connecting Viewmodel in xxx.xaml.cs, like this:



          https://www.c-sharpcorner.com/article/xamarin-forms-create-mvvm-data-binding-application/






          share|improve this answer





















          • With MvvmCross in xaml you put: x:TypeArguments="viewModels:FileInfoViewModel"
            – user3569465
            Nov 13 at 7:58

















          up vote
          0
          down vote













          According to your code, I don’t see where you are linking the (data) ViewModel to (UI)FileInfoPagelian, I guess it is the reason you have this error message.



          Usually, I create Xamarin.Form, the UI is in xxx.xaml, connecting Viewmodel in xxx.xaml.cs, like this:



          https://www.c-sharpcorner.com/article/xamarin-forms-create-mvvm-data-binding-application/






          share|improve this answer





















          • With MvvmCross in xaml you put: x:TypeArguments="viewModels:FileInfoViewModel"
            – user3569465
            Nov 13 at 7:58















          up vote
          0
          down vote










          up vote
          0
          down vote









          According to your code, I don’t see where you are linking the (data) ViewModel to (UI)FileInfoPagelian, I guess it is the reason you have this error message.



          Usually, I create Xamarin.Form, the UI is in xxx.xaml, connecting Viewmodel in xxx.xaml.cs, like this:



          https://www.c-sharpcorner.com/article/xamarin-forms-create-mvvm-data-binding-application/






          share|improve this answer












          According to your code, I don’t see where you are linking the (data) ViewModel to (UI)FileInfoPagelian, I guess it is the reason you have this error message.



          Usually, I create Xamarin.Form, the UI is in xxx.xaml, connecting Viewmodel in xxx.xaml.cs, like this:



          https://www.c-sharpcorner.com/article/xamarin-forms-create-mvvm-data-binding-application/







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 9:53









          Cherry Bu

          84628




          84628












          • With MvvmCross in xaml you put: x:TypeArguments="viewModels:FileInfoViewModel"
            – user3569465
            Nov 13 at 7:58




















          • With MvvmCross in xaml you put: x:TypeArguments="viewModels:FileInfoViewModel"
            – user3569465
            Nov 13 at 7:58


















          With MvvmCross in xaml you put: x:TypeArguments="viewModels:FileInfoViewModel"
          – user3569465
          Nov 13 at 7:58






          With MvvmCross in xaml you put: x:TypeArguments="viewModels:FileInfoViewModel"
          – user3569465
          Nov 13 at 7:58




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222397%2fmvvmcross-logging-mvxlog-no-view-model-association-found-for-candidate-view-ro%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)