Permalink
Browse files

Add StreamingViewModel

- StreamingViewModel is the main page binding context
  • Loading branch information...
ilanolkies committed May 23, 2018
1 parent 289b576 commit 9ab05bc08270fe00a85eca418c8408f714277d06
@@ -39,6 +39,7 @@
<DependentUpon>StreamingExamplePage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StreamingViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Xamarin.Forms.Core">
@@ -5,30 +5,37 @@
namespace StreamingExample
{
public partial class StreamingExamplePage : ContentPage
{
{
private StreamingViewModel ViewModel { get { return (StreamingViewModel)this.BindingContext; } }

public StreamingExamplePage()
{
InitializeComponent();
On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);
On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);

BindingContext = new StreamingViewModel();
}

// Callbacks to images tapped
private void Play_tapped(object sender, EventArgs e)
{
Play.IsVisible = false;
PauseStop.IsVisible = true;
PauseStop.IsVisible = true;
ViewModel.Play();
}

private void Pause_tapped(object sender, EventArgs e)
{
Play.IsVisible = true;
PauseStop.IsVisible = false;
ViewModel.Pause();
}

private void Stop_tapped(object sender, EventArgs e)
{
Play.IsVisible = true;
PauseStop.IsVisible = false;
ViewModel.Stop();
}
}
}
@@ -0,0 +1,23 @@
using System;
namespace StreamingExample
{
public class StreamingViewModel
{
public bool IsPlaying { get; set; } = false;

public void Play()
{
IsPlaying = true;
}

public void Pause()
{
IsPlaying = false;
}

public void Stop()
{
IsPlaying = false;
}
}
}

0 comments on commit 9ab05bc

Please sign in to comment.