Permalink
Browse files

added FabricDataService

  • Loading branch information...
saraford committed Dec 24, 2017
1 parent 9ca3ffe commit 2866d5070092ab9621210566c3e67bf4f76470c5
@@ -60,6 +60,7 @@
<DependentUpon>ItemDetailsPage.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\ItemDetailsViewModel.cs" />
<Compile Include="Services\FabricsDataService.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Xamarin.Forms.Core">
@@ -82,6 +83,7 @@
<Folder Include="Views\" />
<Folder Include="ViewModels\" />
<Folder Include="Models\" />
<Folder Include="Services\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\packages\Xamarin.Forms.2.5.0.121934\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.5.0.121934\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets')" />
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using ListViewInTabbedControl.Models;
namespace ListViewInTabbedControl.Services
{
public static class FabricsDataService
{
public static List<Fabric> GetAllFabrics()
{
List<Fabric> fabrics = new List<Fabric>();
fabrics.Add(new Fabric("fabric1", 5));
fabrics.Add(new Fabric("fabric2", 5));
fabrics.Add(new Fabric("fabric3", 5));
return fabrics;
}
public static void AddFabric(Fabric fabric) {
}
}
}
@@ -35,7 +35,14 @@ public ItemDetailsViewModel(INavigation Navigation, Fabric fabric)
private async void DoneEditing()
{
if (isNew) {
// FabricsDataService.AddFabric(this.Fabric);
MessagingCenter.Send<ItemDetailsViewModel, Fabric>(this, "added", this.Fabric);
} else {
// FabricsDataService.UpdateFabric(this.Fabric);
}
await Navigation.PopAsync();
@@ -6,26 +6,25 @@
using System.Collections.Generic;
using System.Windows.Input;
using ListViewInTabbedControl.Views;
using ListViewInTabbedControl.Services;
namespace ListViewInTabbedControl.ViewModels
{
public class PageOneViewModel : BaseViewModel
{
// this ObservableCollection is *only* for the View
// do *not* use this as the "source of truth" for fabrics
public ObservableCollection<Fabric> OCFabrics { get; set; }
public ObservableRangeCollection<Fabric> OCFabrics { get; set; }
public ICommand AddFabricCommand { get; private set; }
private INavigation Navigation;
public PageOneViewModel(INavigation Navigation)
{
OCFabrics = new ObservableCollection<Fabric>();
OCFabrics = new ObservableRangeCollection<Fabric>();
OCFabrics.Add(new Fabric("fabric1", 5));
OCFabrics.Add(new Fabric("fabric2", 5));
OCFabrics.Add(new Fabric("fabric3", 5));
var allFabrics = FabricsDataService.GetAllFabrics();
OCFabrics.AddRange(allFabrics);
Title = "Page One from VM";
this.Navigation = Navigation;

0 comments on commit 2866d50

Please sign in to comment.