Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements Carousel control and sample carousel page #712

Merged
merged 30 commits into from
Mar 20, 2017
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d058391
Implements Carousel control and sample carousel page
Mimetis Dec 13, 2016
4a047f3
adding the carousel header, using build.ps1 powershell script
Mimetis Dec 13, 2016
ccc6eb2
Merge branch 'master' of https://github.com/Mimetis/UWPCommunityToolk…
Mimetis Feb 15, 2017
962b5b0
New Carousel Control. Inherits from ItemsControl, Keyboard and mouse …
Feb 25, 2017
d924275
XamlStyler pase
Feb 25, 2017
ba54cf2
Update Headers
Feb 25, 2017
6ccfc24
Modifications from request changes
Mimetis Mar 2, 2017
a3d6f63
Deleting unecessary comments :)
Mimetis Mar 2, 2017
1cc74cf
Add focus visual style
Mimetis Mar 9, 2017
9beeb77
Add SelectedItem property
Mimetis Mar 9, 2017
b927b4e
merge conflicts
Mimetis Mar 9, 2017
2cf15d5
typos corrections, remove unused using statements, remove this keywor…
Mimetis Mar 9, 2017
1099787
correcting a bug preventing the carousel to show after first load
Mimetis Mar 9, 2017
984ad62
Change depth property type to int
Mimetis Mar 10, 2017
881f46e
Removing Manipulations from the Carousel control and set the Backgrou…
Mimetis Mar 10, 2017
10ee204
Correcting else if
Mimetis Mar 10, 2017
661a277
removing reference to CarouselPanel into Carousel control
Mimetis Mar 10, 2017
a44dee5
Trying to make a better description for InvertPositive property
Mimetis Mar 10, 2017
3ab35bd
fixed conflicts
nmetulev Mar 13, 2017
5f062f8
updated directional navigation to work better for xbox
nmetulev Mar 13, 2017
53e9abd
added AutomationProperty.Name
nmetulev Mar 13, 2017
84a8f64
fixed merge conflict yet again
nmetulev Mar 13, 2017
2ed36cc
Merge branch 'dev' into Mimetis-dev
nmetulev Mar 16, 2017
649baef
updated focus management of carousel
nmetulev Mar 16, 2017
e2634ec
playing with inertia
nmetulev Mar 16, 2017
2603354
continuing inertia investigation
nmetulev Mar 17, 2017
41938a9
Merge branch 'dev' of https://github.com/Microsoft/UWPCommunityToolki…
Mimetis Mar 17, 2017
41c4fd8
Merge remote-tracking branch 'refs/remotes/upstream/Mimetis-dev'
Mimetis Mar 17, 2017
b395692
Adding docs for Carousel control
Mimetis Mar 20, 2017
186e526
Fixing typos
Mimetis Mar 20, 2017
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 @@ -235,6 +235,7 @@
<Content Include="SamplePages\Bing Service\icon.png" />
<Content Include="SamplePages\BladeView\BladeView.png" />
<Content Include="SamplePages\Blur\BlurBehavior.png" />
<Content Include="SamplePages\Carousel\Carousel.png" />
<Content Include="SamplePages\DropShadowPanel\DropShadowPanel.png" />
<Content Include="SamplePages\FadeHeader\FadeHeaderBehavior.png" />
<Content Include="SamplePages\DropShadowPanel\Trex.png" />
Expand Down Expand Up @@ -328,6 +329,7 @@
<Content Include="SamplePages\SystemInformation\SystemInformationCode.bind" />
<Content Include="SamplePages\DispatcherHelper\DispatcherHelperCode.bind" />
<Content Include="SamplePages\TextBoxMask\TextBoxMask.bind" />
<Content Include="SamplePages\Carousel\Carousel.bind" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
Expand All @@ -340,6 +342,9 @@
<Compile Include="Common\DelegateCommand.cs" />
<Compile Include="Common\Tools.cs" />
<Compile Include="Models\Email.cs" />
<Compile Include="SamplePages\Carousel\Carousel.xaml.cs">
<DependentUpon>Carousel.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\ConnectionHelper\ConnectionHelperPage.xaml.cs">
<DependentUpon>ConnectionHelperPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -506,6 +511,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SamplePages\Carousel\Carousel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\ConnectionHelper\ConnectionHelperPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
46 changes: 46 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Carousel/Carousel.bind
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.Carousel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why all this spaces ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, I have made the corrections

<Grid Background="{StaticResource Brush-Grey-05}">

<Border Margin="0">

<controls:Carousel ItemsSource="{Binding Datas}" Background="{StaticResource Brush-Grey-05}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure xaml in the bind file matches the xaml in the actual page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

x:Name="carouselControl"
SelectedIndex="@[SelectedIndex:String:4]"
ItemDepth="@[ItemDepth:Slider:50:0-400]"
Orientation="@[Orientation:Enum:Orientation.Horizontal]"
ItemMargin="@[ItemMargin:Slider:0:0-500]"
ItemRotationX="@[ItemRotationX:Slider:0:0-180]"
ItemRotationY="@[ItemRotationY:Slider:45:0-180]"
ItemRotationZ ="@[ItemRotationZ:Slider:0:0-180]"
InvertPositive="@[InvertPositive:Bool:True]"
>
<controls:Carousel.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</controls:Carousel.EasingFunction>
<controls:Carousel.ItemTemplate>
<DataTemplate>
<Grid >
<Grid.RowDefinitions>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the Rows or even the Grid itself. Template can just be the Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, corrected

<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Source="{Binding BitmapImage}" Width="200" Height="100" VerticalAlignment="Bottom"
Stretch="Uniform"></Image>
</Grid>
</DataTemplate>
</controls:Carousel.ItemTemplate>

</controls:Carousel>
</Border>
</Grid>
</Page>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Carousel/Carousel.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.Carousel"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name should have the 'Page' suffix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, corrected

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to use XamlStyler in Xaml pages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

mc:Ignorable="d">




<Grid Background="{StaticResource Brush-Grey-05}">

<Border Margin="0">

<controls:Carousel x:Name="carouselControl"
Background="{StaticResource Brush-Grey-05}"
InvertPositive="{Binding InvertPositive.Value, Mode=OneWay}"
ItemDepth="{Binding ItemDepth.Value, Mode=OneWay}"
ItemMargin="{Binding ItemMargin.Value, Mode=OneWay}"
ItemRotationX="{Binding ItemRotationX.Value, Mode=OneWay}"
ItemRotationY="{Binding ItemRotationY.Value, Mode=OneWay}"
ItemRotationZ="{Binding ItemRotationZ.Value, Mode=OneWay}"
Orientation="{Binding Orientation.Value, Mode=OneWay}"
SelectedIndex="{Binding SelectedIndex.Value, Mode=TwoWay}">
<controls:Carousel.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</controls:Carousel.EasingFunction>
<controls:Carousel.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Width="200"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, corrected

Height="200"
VerticalAlignment="Bottom"
Source="{Binding BitmapImage}"
Stretch="Uniform" />
</Grid>
</DataTemplate>
</controls:Carousel.ItemTemplate>

</controls:Carousel>
</Border>



</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using Microsoft.Toolkit.Uwp.SampleApp.Models;
using System;
using System.Collections.ObjectModel;
using System.Linq;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The using statements need to be rearranged and the non used need to be removed.

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
/// <summary>
/// A page that shows how to use the DropShadowPanel control.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be DropShadowPanel control :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ah correct :) Copy / Paste "is not" a friend !!

/// </summary>
public sealed partial class Carousel : Page
{
/// <summary>
/// Initializes a new instance of the <see cref="Carousel"/> class.
/// </summary>
public Carousel()
{
InitializeComponent();
}

public ObservableCollection<CarouselData> Datas { get; set; }

/// <summary>
/// Invoked when the Page is loaded and becomes the current source of a parent Frame.
/// </summary>
/// <param name="e">Event data that can be examined by overriding code. The event data is representative of the pending navigation that will load the current Page. Usually the most relevant property to examine is Parameter.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);

var propertyDesc = e.Parameter as PropertyDescriptor;

if (propertyDesc != null)
{
DataContext = propertyDesc.Expando;
}

var datas = new ObservableCollection<CarouselData>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Images can be obtained from the PhotosDataSource class.

carouselControl.ItemsSource = await new Data.PhotosDataSource().GetItemsAsync()

All of the images were actually changed from pngs to jpgs recently

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the tips, I changed the way sample work :)

datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/BigFourSummerHeat.png", UriKind.Absolute)), Title = "01" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/BisonBadlandsChillin.png", UriKind.Absolute)), Title = "02" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/ColumbiaRiverGorge.png", UriKind.Absolute)), Title = "03" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/SnowyInterbayt.png", UriKind.Absolute)), Title = "04" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/GrandTetons.png", UriKind.Absolute)), Title = "05" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/LakeAnnMushroom.png", UriKind.Absolute)), Title = "06" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/MilkyWayStHelensHikePurple.png", UriKind.Absolute)), Title = "08" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/MilkyWayStHelensHikePurple.png", UriKind.Absolute)), Title = "10" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/MitchellButtes.png", UriKind.Absolute)), Title = "11" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/MultnomahFalls.png", UriKind.Absolute)), Title = "12" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/NorthernCascadesReflection.png", UriKind.Absolute)), Title = "13" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/NovemberHikeWaterfall.png", UriKind.Absolute)), Title = "14" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/Owl.png", UriKind.Absolute)), Title = "15" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/ColumbiaRiverGorge.png", UriKind.Absolute)), Title = "03" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/SnowyInterbayt.png", UriKind.Absolute)), Title = "04" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/GrandTetons.png", UriKind.Absolute)), Title = "05" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/LakeAnnMushroom.png", UriKind.Absolute)), Title = "06" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/MilkyWayStHelensHikePurple.png", UriKind.Absolute)), Title = "08" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/MilkyWayStHelensHikePurple.png", UriKind.Absolute)), Title = "10" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/MitchellButtes.png", UriKind.Absolute)), Title = "11" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/MultnomahFalls.png", UriKind.Absolute)), Title = "12" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/NorthernCascadesReflection.png", UriKind.Absolute)), Title = "13" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/NovemberHikeWaterfall.png", UriKind.Absolute)), Title = "14" });
datas.Add(new CarouselData { BitmapImage = new BitmapImage(new Uri("ms-appx:///Assets/Photos/Owl.png", UriKind.Absolute)), Title = "15" });

this.Datas = datas;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this keyword as it is useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, to be honest, using this or not is a "coding style" and I use "this" every time I can, to make my code the most readable as possible.
I know we can have a long long debate about this.
But anyway, is adding "this" or not, Something so important in this case ? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is important as it is part of our guideline :) we need to keep the same coding style for the entire project

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will delete all the "this" keywords if they're not necessary :)


carouselControl.ItemsSource = Datas;
}
}

public class CarouselData
{
public BitmapImage BitmapImage { get; set; }

public string Title { get; set; }
}
}
8 changes: 8 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
"Name": "Controls",
"Icon": "Icons/Foundation.png",
"Samples": [
{
"Name": "Carousel",
"Type": "Carousel",
"About": "Presents items in a carousel control. It reacts to changes in the layout as well as the content so it can adapt to different form factors automatically.",
"CodeUrl": "https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/Carousel",
"XamlCodeFile": "Carousel.bind",
"Icon": "/SamplePages/Carousel/Carousel.png"
},
{
"Name": "AdaptiveGridView",
"Type": "AdaptiveGridViewPage",
Expand Down
Loading