Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.3.0.819712-pre2" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Essentials" Version="1.3.0" />
<PackageReference Include="Xamarin.Forms" Version="4.3.0.851321-pre3" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down Expand Up @@ -100,5 +100,20 @@
<Name>CarouselViewChallenge</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\HealthyLifeStyle.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\Exercise.jpg" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\food.jpg" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\stress.jpg" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\water.jpg" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text;

namespace CarouselViewChallenge.ViewModels
{
public class Sample
{
public string Title { get; set; }
public string Image { get; set; }
}
public class CarouselModel: INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

private ObservableCollection<Sample> _sections;
public ObservableCollection<Sample> Sections
{
get
{
return _sections;
}
set
{
if (_sections != value)
{
_sections = value;
OnPropertyChanged(new PropertyChangedEventArgs("Sections"));
}
}
}

private void OnPropertyChanged(PropertyChangedEventArgs eventArgs)
{
PropertyChanged?.Invoke(this, eventArgs);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="CarouselViewChallenge.Views.CarouselViewChallengePage">
<ContentPage.Content>
<StackLayout BackgroundColor="#cfd8dc">
<Label Text="You can use this page for the CarouselView Challenge!" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
</StackLayout>
</ContentPage.Content>
<CarouselView ItemsSource="{Binding Sections}" PeekAreaInsets="50">
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout BackgroundColor="#cfd8dc">
<Frame BorderColor="Gray" Margin="8" HasShadow="True" HeightRequest="300" VerticalOptions="CenterAndExpand">
<StackLayout>
<Label Text="{Binding Title}" FontSize="24" FontAttributes="Bold" HorizontalTextAlignment="Center"/>
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Image Source="{Binding Image}" Margin="0,50,0,0"></Image>

</StackLayout>

</StackLayout>
</Frame>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using CarouselViewChallenge.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -12,9 +14,45 @@ namespace CarouselViewChallenge.Views
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CarouselViewChallengePage : ContentPage
{
public CarouselModel VM { get; set; }
public CarouselViewChallengePage()
{
InitializeComponent();
VM = new CarouselModel();
VM.Sections = new ObservableCollection<Sample>
{
new Sample
{
Title = "Healthy LifeStyle Tips",
Image = "HealthyLifeStyle.png",

},
new Sample
{
Image = "Exercise.jpg",
Title = "1: Exercise Reguarly",
},
new Sample
{
Title = "2: Eat Healthy",
Image = "food.jpg",

},
new Sample
{
Title = "3: Drink Plenty of Water",
Image = "water.jpg",

},
new Sample
{
Title = "4: Reduce Stress",
Image = "stress.png",

},

BindingContext = VM;
}

}
}