title: Xamarin Multiple Binding Context on same View with different ViewModels
body: <p>I have a <code>ContentPage</code> with 2 different ViewModels (<code>RssFornecedores</code>, <code>RssProdutos</code>) and I am having problems binding them in the same <code>ContentPage</code>
  I tried to do something like this:</p>
  <p><a href="https://stackoverflow.com/questions/50307356/multiple-bindingcontexts-on-same-contentpage-two-different-views">Multiple BindingContext&#39;s On Same ContentPage, Two different Views?</a></p>
  <p>But it didn't work because of the following error:</p>
  <blockquote>
  <p>Type 'viewModels:RssProdutos' is used like a markup extension but does not derive from MarkupExtension</p>
  </blockquote>
  <p>And if I add as a <code>StaticResource</code> <code>BindingContext=&quot;{Binding Produto, Source = {StaticResource viewModels:RssProdutos}}&quot;</code> I get the error:</p>
  <blockquote>
  <p>StaticResource not found for key staticviewModels:RssProdutos'</p>
  </blockquote>
  <p>Documentos.xaml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
  &lt;ContentPage xmlns=&quot;http://xamarin.com/schemas/2014/forms&quot;
               xmlns:x=&quot;http://schemas.microsoft.com/winfx/2009/xaml&quot; 
               xmlns:viewModels=&quot;clr-namespace:AppQ4evo.ViewModels&quot; 
               xmlns:controls=&quot;clr-namespace:AppQ4evo.CSS&quot;
               x:Class=&quot;AppQ4evo.Views.Documentos&quot;           
               BackgroundColor=&quot;White&quot;&gt;
  
      &lt;ContentPage.BindingContext&gt;
          &lt;viewModels:RssTerceiros /&gt;
      &lt;/ContentPage.BindingContext&gt;
  
      &lt;!--Common Styles Starts--&gt;
      &lt;ContentPage.Resources&gt;
          &lt;ResourceDictionary&gt;
  
              &lt;Color x:Key=&quot;LightGreenColor&quot;&gt;#2FA999&lt;/Color&gt;
              &lt;Color x:Key=&quot;BorderColor&quot;&gt;#D8D8D8&lt;/Color&gt;
  
              &lt;Style x:Key=&quot;LableStyle&quot; TargetType=&quot;Label&quot;&gt;
                  &lt;Setter Property=&quot;TextColor&quot; Value=&quot;#666666&quot; /&gt;
                  &lt;Setter Property=&quot;FontSize&quot; Value=&quot;Large&quot; /&gt;
              &lt;/Style&gt;
              &lt;Style x:Key=&quot;FrameStyle&quot; TargetType=&quot;Frame&quot;&gt;
                  &lt;Setter Property=&quot;HasShadow&quot; Value=&quot;False&quot; /&gt;
                  &lt;Setter Property=&quot;Padding&quot; Value=&quot;0&quot; /&gt;
                  &lt;Setter Property=&quot;CornerRadius&quot; Value=&quot;5&quot; /&gt;
                  &lt;Setter Property=&quot;BorderColor&quot; Value=&quot;{StaticResource BorderColor}&quot; /&gt;
              &lt;/Style&gt;
              &lt;Style x:Key=&quot;EntryStyle&quot; TargetType=&quot;Entry&quot;&gt;
                  &lt;Setter Property=&quot;HeightRequest&quot; Value=&quot;40&quot;&gt;&lt;/Setter&gt;
                  &lt;Setter Property=&quot;Margin&quot; Value=&quot;5,0,0,0&quot;&gt;&lt;/Setter&gt;
              &lt;/Style&gt;
          &lt;/ResourceDictionary&gt;
      &lt;/ContentPage.Resources&gt;
      &lt;!--Common Styles Ends--&gt;
  
      &lt;ContentPage.ToolbarItems&gt;
          &lt;ToolbarItem x:Name=&quot;iconAttach&quot; Text=&quot;Documentos&quot; Order=&quot;Primary&quot; Icon=&quot;attach.png&quot; Priority=&quot;-1&quot; Clicked=&quot;Button_Clicked_AnexosAsync&quot; /&gt;
      &lt;/ContentPage.ToolbarItems&gt;
  
      &lt;NavigationPage.TitleView&gt;
          &lt;StackLayout Orientation=&quot;Horizontal&quot; VerticalOptions=&quot;Center&quot; HorizontalOptions=&quot;Center&quot;&gt;
              &lt;Label Text=&quot;Documentos&quot; FontSize=&quot;18&quot; FontAttributes=&quot;Bold&quot; TextColor=&quot;White&quot; VerticalTextAlignment=&quot;Center&quot; /&gt;
          &lt;/StackLayout&gt;
      &lt;/NavigationPage.TitleView&gt;
  
      &lt;ContentPage.Content&gt;
          &lt;AbsoluteLayout Padding=&quot;0&quot; VerticalOptions=&quot;FillAndExpand&quot; HorizontalOptions=&quot;FillAndExpand&quot;&gt;
              &lt;StackLayout&gt;
                  &lt;Grid x:Name=&quot;docs&quot; Padding=&quot;-2&quot;&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                          &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                          &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                          &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                      &lt;/Grid.RowDefinitions&gt;
  
                      &lt;StackLayout Grid.Row=&quot;0&quot; Margin=&quot;10,20&quot;&gt;
                          &lt;Grid&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width=&quot;360&quot; /&gt;
                                  &lt;ColumnDefinition Width=&quot;*&quot; /&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
                              &lt;Frame Style=&quot;{StaticResource FrameStyle}&quot;&gt;
                                  &lt;controls:CustomEntry x:Name=&quot;DataDocEntry&quot; Grid.Column=&quot;0&quot; Text=&quot;{Binding Date, StringFormat='{0:MMMM dd, yyyy}', Source={x:Reference MainDatePicker}}&quot; IsEnabled=&quot;false&quot; Style=&quot;{StaticResource EntryStyle}&quot; /&gt;
                              &lt;/Frame&gt;
                              &lt;DatePicker x:Name=&quot;MainDatePicker&quot; Grid.Column=&quot;1&quot; MinimumDate=&quot;1/1/2018&quot; MaximumDate=&quot;12/31/2030&quot; HeightRequest=&quot;30&quot; BackgroundColor=&quot;Gray&quot; Opacity=&quot;0&quot;  /&gt;
                              &lt;Image VerticalOptions=&quot;Center&quot; Grid.Column=&quot;1&quot; HorizontalOptions=&quot;End&quot; Source=&quot;icalendar.png&quot; HeightRequest=&quot;30&quot; WidthRequest=&quot;30&quot;&gt;
                                  &lt;Image.GestureRecognizers&gt;
                                      &lt;TapGestureRecognizer Tapped=&quot;Calendario_Clicked&quot; NumberOfTapsRequired=&quot;1&quot; /&gt;
                                  &lt;/Image.GestureRecognizers&gt;
                              &lt;/Image&gt;
                          &lt;/Grid&gt;
                          &lt;Frame Style=&quot;{StaticResource FrameStyle}&quot;&gt;
                              &lt;controls:CustomEntry x:Name=&quot;NumExternoEntry&quot; Placeholder=&quot;Número Externo&quot; Keyboard=&quot;Numeric&quot; /&gt;
                          &lt;/Frame&gt;
                          &lt;Frame Style=&quot;{StaticResource FrameStyle}&quot;&gt;
                              &lt;controls:CustomPicker x:Name=&quot;FornecedorEntry&quot; Title=&quot;Selecionar Fornecedor&quot;  /&gt;
                          &lt;/Frame&gt;
                      &lt;/StackLayout&gt;
  
                      &lt;StackLayout Grid.Row=&quot;1&quot; Margin=&quot;0,-10&quot;&gt;
                          &lt;Button x:Name=&quot;btnAdd&quot; Text=&quot;Adicionar&quot; Clicked=&quot;btnAddPopup_Clicked&quot; /&gt;
                      &lt;/StackLayout&gt;
  
                      &lt;Grid x:Name=&quot;ListViewHeaders&quot; Grid.Row=&quot;2&quot; Margin=&quot;0,20,0,0&quot;&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height=&quot;40&quot;/&gt;
                              &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width=&quot;*&quot;/&gt;
                              &lt;ColumnDefinition Width=&quot;60&quot; /&gt;
                              &lt;ColumnDefinition Width=&quot;65&quot; /&gt;
                              &lt;ColumnDefinition Width=&quot;80&quot; /&gt;
                              &lt;ColumnDefinition Width=&quot;25&quot; /&gt;
                              &lt;ColumnDefinition Width=&quot;60&quot; /&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;BoxView Color=&quot;Black&quot; Grid.Row=&quot;0&quot; Grid.ColumnSpan=&quot;8&quot; HeightRequest=&quot;0.5&quot; /&gt;
                          &lt;BoxView Color=&quot;DimGray&quot; Grid.Row=&quot;0&quot; Grid.ColumnSpan=&quot;8&quot; /&gt;
                          &lt;Label Grid.Column=&quot;1&quot; Text=&quot;Produto&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;White&quot; FontAttributes=&quot;Bold&quot; FontSize=&quot;Small&quot;/&gt;
                          &lt;Label Grid.Column=&quot;2&quot; Text=&quot;Descrição&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;White&quot; FontAttributes=&quot;Bold&quot; FontSize=&quot;Small&quot;/&gt;
                          &lt;Label Grid.Column=&quot;3&quot; Text=&quot;Observação&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;White&quot; FontAttributes=&quot;Bold&quot; FontSize=&quot;Small&quot;/&gt;
                          &lt;Label Grid.Column=&quot;4&quot; Text=&quot;Qtd&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;White&quot; FontAttributes=&quot;Bold&quot; FontSize=&quot;Small&quot;/&gt;
                          &lt;Label Grid.Column=&quot;5&quot; Text=&quot;Valor Unitário&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;White&quot; FontAttributes=&quot;Bold&quot; FontSize=&quot;Small&quot;/&gt;
                          &lt;Label Grid.Column=&quot;6&quot; Text=&quot;IVA&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;White&quot; FontAttributes=&quot;Bold&quot; FontSize=&quot;Small&quot;/&gt;
                      &lt;/Grid&gt;
                      &lt;ListView x:Name=&quot;DocumentsList&quot; ItemsSource=&quot;{Binding DocumentsList, Source = {viewModels:RssProdutos}}&quot; Grid.Row=&quot;2&quot; HasUnevenRows=&quot;True&quot; Margin=&quot;0,60&quot; BackgroundColor=&quot;White&quot;&gt;
                          &lt;ListView.ItemTemplate&gt;
                              &lt;DataTemplate&gt;
                                  &lt;ViewCell&gt;
                                      &lt;ViewCell.View&gt;
                                          &lt;Grid&gt;
                                              &lt;Grid.RowDefinitions&gt;
                                                  &lt;RowDefinition Height=&quot;30&quot;&gt;&lt;/RowDefinition&gt;
                                              &lt;/Grid.RowDefinitions&gt;
                                              &lt;Grid.ColumnDefinitions&gt;
                                                  &lt;ColumnDefinition Width=&quot;30&quot;&gt;&lt;/ColumnDefinition&gt;
                                                  &lt;ColumnDefinition Width=&quot;50&quot;&gt;&lt;/ColumnDefinition&gt;
                                                  &lt;ColumnDefinition Width=&quot;70&quot;&gt;&lt;/ColumnDefinition&gt;
                                                  &lt;ColumnDefinition Width=&quot;80&quot;&gt;&lt;/ColumnDefinition&gt;
                                                  &lt;ColumnDefinition Width=&quot;30&quot;&gt;&lt;/ColumnDefinition&gt;
                                                  &lt;ColumnDefinition Width=&quot;50&quot;&gt;&lt;/ColumnDefinition&gt;
                                                  &lt;ColumnDefinition Width=&quot;45&quot;&gt;&lt;/ColumnDefinition&gt;
                                              &lt;/Grid.ColumnDefinitions&gt;
                                              &lt;Label x:Name=&quot;ProdutoLabel&quot; Grid.Row=&quot;0&quot; Grid.Column=&quot;1&quot; BindingContext=&quot;{Binding Produto, Source = {viewModels:RssProdutos}}&quot; Text=&quot;{Binding Produto}&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;Black&quot; FontAttributes=&quot;Bold&quot;/&gt;
                                              &lt;!--&lt;Label Grid.Row=&quot;0&quot; Grid.Column=&quot;2&quot; Text=&quot;{Binding Descricao}&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;Black&quot; FontAttributes=&quot;Bold&quot;/&gt;
                                              &lt;Label Grid.Row=&quot;0&quot; Grid.Column=&quot;3&quot; Text=&quot;{Binding Observacao}&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;Black&quot; FontAttributes=&quot;Bold&quot;/&gt;
                                              &lt;Label Grid.Row=&quot;0&quot; Grid.Column=&quot;4&quot; Text=&quot;{Binding Quantidade}&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;Black&quot; FontAttributes=&quot;Bold&quot;/&gt;
                                              &lt;Label Grid.Row=&quot;0&quot; Grid.Column=&quot;5&quot; Text=&quot;{Binding ValorUnitario}&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;Black&quot; FontAttributes=&quot;Bold&quot;/&gt;
                                              &lt;Label Grid.Row=&quot;0&quot; Grid.Column=&quot;6&quot; Text=&quot;{Binding Iva}&quot; XAlign=&quot;Center&quot; YAlign=&quot;Center&quot; TextColor=&quot;Black&quot; FontAttributes=&quot;Bold&quot;/&gt;--&gt;
                                          &lt;/Grid&gt;
                                      &lt;/ViewCell.View&gt;
                                  &lt;/ViewCell&gt;
                              &lt;/DataTemplate&gt;
                          &lt;/ListView.ItemTemplate&gt;
                      &lt;/ListView&gt;
                  &lt;/Grid&gt;
              &lt;/StackLayout&gt;
              &lt;ContentView x:Name=&quot;popupAddDocumentView&quot; Margin=&quot;40,120&quot; Padding=&quot;10,0&quot; IsVisible=&quot;false&quot;&gt;
                  &lt;StackLayout VerticalOptions=&quot;Center&quot; HorizontalOptions=&quot;Center&quot;&gt;
                      &lt;StackLayout Orientation=&quot;Vertical&quot; HeightRequest=&quot;400&quot; WidthRequest=&quot;300&quot; BackgroundColor=&quot;Gray&quot;&gt;
                          &lt;Image HorizontalOptions=&quot;End&quot; Source=&quot;close.png&quot; HeightRequest=&quot;20&quot; WidthRequest=&quot;20&quot;&gt;
                              &lt;Image.GestureRecognizers&gt;
                                  &lt;TapGestureRecognizer Tapped=&quot;OnImageNameTapped_ClosePopup&quot; NumberOfTapsRequired=&quot;1&quot; /&gt;
                              &lt;/Image.GestureRecognizers&gt;
                          &lt;/Image&gt;
                          &lt;Entry x:Name=&quot;ProdutoEntry&quot; Margin=&quot;20,0,20,0&quot; Placeholder=&quot;Produto&quot; /&gt;
                          &lt;Entry x:Name=&quot;DescricaoEntry&quot; Margin=&quot;20,0,20,0&quot; Placeholder=&quot;Descrição&quot; /&gt;
                          &lt;Entry x:Name=&quot;ObservacaoEntry&quot; Margin=&quot;20,0,20,0&quot; Placeholder=&quot;Observação&quot; /&gt;
                          &lt;Entry x:Name=&quot;QuantidadeEntry&quot; Margin=&quot;20,0,20,0&quot; Placeholder=&quot;Quantidade&quot; /&gt;
                          &lt;Entry x:Name=&quot;ValorUnitarioEntry&quot; Margin=&quot;20,0,20,0&quot; Placeholder=&quot;Valor&quot; /&gt;
                          &lt;Entry x:Name=&quot;IvaEntry&quot; Margin=&quot;20,0,20,0&quot; Placeholder=&quot;IVA&quot; /&gt;
                          &lt;Button x:Name=&quot;btnAddDocument&quot; Margin=&quot;20,0,20,0&quot; Clicked=&quot;btnAddDocument_Clicked&quot; Text=&quot;Adicionar&quot; /&gt;
                      &lt;/StackLayout&gt;
                  &lt;/StackLayout&gt;
              &lt;/ContentView&gt;
          &lt;/AbsoluteLayout&gt;
      &lt;/ContentPage.Content&gt;
  &lt;/ContentPage&gt; 
  </code></pre>
  <p>Best regards</p>