Permalink
Browse files

working listview

  • Loading branch information...
saraford committed Dec 22, 2017
1 parent f8b7501 commit 239187a18cf849149979f96eb7f4f5dfa4a53d21
@@ -37,6 +37,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="Views\ItemDetailsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
@@ -52,6 +56,10 @@
<Compile Include="ViewModels\PageOneViewModel.cs" />
<Compile Include="ViewModels\PageTwoViewModel.cs" />
<Compile Include="Models\Fabric.cs" />
<Compile Include="Views\ItemDetailsPage.xaml.cs">
<DependentUpon>ItemDetailsPage.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\ItemDetailsViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Xamarin.Forms.Core">
@@ -0,0 +1,19 @@
using System;
using ListViewInTabbedControl.Models;
using MvvmHelpers;
using Xamarin.Forms;
namespace ListViewInTabbedControl.ViewModels
{
public class ItemDetailsViewModel : BaseViewModel
{
//private Fabric fabric;
private INavigation Navigation;
public ItemDetailsViewModel(INavigation Navigation, Fabric fabric)
{
Title = "Hello from Item " + fabric.Name;
this.Navigation = Navigation;
}
}
}
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ListViewInTabbedControl.Views.ItemDetailsPage"
Title="{Binding Title}">
<ContentPage.Content>
<StackLayout>
<Label Text="{Binding Title}"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using ListViewInTabbedControl.ViewModels;
using Xamarin.Forms;
using ListViewInTabbedControl.Models;
namespace ListViewInTabbedControl.Views
{
public partial class ItemDetailsPage : ContentPage
{
public ItemDetailsPage(Fabric fabric)
{
InitializeComponent();
var itemDetailsViewModel = new ItemDetailsViewModel(this.Navigation, fabric);
this.BindingContext = itemDetailsViewModel;
}
}
}
@@ -5,7 +5,8 @@
Title="{Binding Title}">
<ContentPage.Content>
<StackLayout>
<ListView ItemsSource="{Binding OCFabrics}"
<ListView ItemsSource="{Binding OCFabrics}"
ItemTapped="Handle_ItemTapped"
SelectedItem="{Binding SelectedItem, Mode=OneWay}"
HasUnevenRows="True"
Margin="10,10,0,0">
@@ -2,17 +2,30 @@
using System.Collections.Generic;
using ListViewInTabbedControl.ViewModels;
using Xamarin.Forms;
using ListViewInTabbedControl.Models;
using ListViewInTabbedControl.Views;
namespace ListViewInTabbedControl.Views
{
public partial class Page1 : ContentPage
{
public Page1()
{
InitializeComponent();
var pageOneViewModel = new PageOneViewModel(this.Navigation);
this.BindingContext = pageOneViewModel;
}
async void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
{
Fabric tappedFabric = e.Item as Fabric;
if (tappedFabric == null)
return;
await this.Navigation.PushModalAsync(new NavigationPage(new ItemDetailsPage(tappedFabric)));
}
}
}

0 comments on commit 239187a

Please sign in to comment.