-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Changes from 8 commits
d058391
4a047f3
ccc6eb2
962b5b0
d924275
ba54cf2
6ccfc24
a3d6f63
1cc74cf
9beeb77
b927b4e
2cf15d5
1099787
984ad62
881f46e
10ee204
661a277
a44dee5
3ab35bd
5f062f8
53e9abd
84a8f64
2ed36cc
649baef
e2634ec
2603354
41938a9
41c4fd8
b395692
186e526
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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"> | ||
|
||
|
||
|
||
<Grid Background="{StaticResource Brush-Grey-05}"> | ||
|
||
<Border Margin="0"> | ||
|
||
<controls:Carousel ItemsSource="{Binding Datas}" Background="{StaticResource Brush-Grey-05}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.Carousel" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Class name should have the 'Page' suffix There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to use XamlStyler in Xaml pages There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure all xaml has gone through the xaml styler: https://github.com/Microsoft/UWPCommunityToolkit/blob/master/contributing.md#quality-insurance-for-pull-requests-for-xaml-controls There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be DropShadowPanel control :) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Images can be obtained from the
All of the images were actually changed from pngs to jpgs recently There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this keyword as it is useless. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all this spaces ?
There was a problem hiding this comment.
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