CarouselPanel Task Based Help > Limiting the Number of Visible Elements |
You can customize the number of visible elements in the CarouselPanel by setting properties in either the <c1:C1CarouselPanel> tag in the ItemsPanelTemplate or in the <ItemsControl> tag.
In the C1CarouselPanel TagTo limit the number of visible elements in the CarouselPanel follow these steps:
xmlns:c1=http://schemas.componentone.com/winfx/2006/xaml
The namespaces will now appear similar to the following:
WPF XAML |
Copy Code
|
---|---|
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> |
Silverlight XAML |
Copy Code
|
---|---|
<UserControl x:Class="QuickStart.MainPage" xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> |
WPF XAML |
Copy Code
|
---|---|
<Window.Resources> </Window.Resources> |
Silverlight XAML |
Copy Code
|
---|---|
<UserControl.Resources> </UserControl.Resources> |
You will add templates within this tag.
XAML |
Copy Code
|
---|---|
<ItemsPanelTemplate x:Key="carouselPanelTemplate"> <c1:C1CarouselPanel Padding="0, 10, 50, 50" VerticalPathAlignment="Center" HorizontalItemAnchorOnPath="Center" VerticalItemAnchorOnPath="Center"/> </ItemsPanelTemplate> |
PageSize="3"
The total <c1:C1CarouselPanel> markup should resemble the following:
XAML |
Copy Code
|
---|---|
<c1:C1CarouselPanel Padding="0, 10, 50, 50" VerticalPathAlignment="Center" HorizontalItemAnchorOnPath="Center" VerticalItemAnchorOnPath="Center" PageSize="3"/> |
XAML |
Copy Code
|
---|---|
<DataTemplate x:Key="carouselItemTemplate"> <Image Source="{Binding}" Stretch="None" /> </DataTemplate> |
XAML |
Copy Code
|
---|---|
<Style x:Key="diagonalPanelStyle" TargetType="ListBox"> <Setter Property="c1:C1CarouselPanel.PathGeometry" Value="M 216, 60 L 600, 390"/> <Setter Property="c1:C1CarouselPanel.HorizontalPathAlignment" Value="Left"/> <Setter Property="c1:C1CarouselPanel.VerticalPathAlignment" Value="Top"/> <Setter Property="c1:C1CarouselPanel.PerspectiveAngle" Value="65"/> <Setter Property="c1:C1CarouselPanel.PerspectiveFactor" Value="0.12"/> </Style> |
XAML |
Copy Code
|
---|---|
<ListBox Background="Transparent" Name="carouselListBox" Grid.Row="1" ItemsPanel="{StaticResource carouselPanelTemplate}" ItemTemplate="{StaticResource carouselItemTemplate}" Style="{StaticResource diagonalPanelStyle}"/> |
WPF |
Copy Code
|
---|---|
Visual Basic: Imports System.Windows.Media.Imaging; Imports C1.WPF; Imports C1.WPF.Carousel; C#: using System.Windows.Media.Imaging; using C1.WPF; using C1.WPF.Carousel; |
Silverlight |
Copy Code
|
---|---|
Visual Basic: Imports System.Windows.Media.Imaging Imports C1.Silverlight Imports C1.Silverlight.Carousel C#: using System.Windows.Media.Imaging; using C1.Silverlight; using C1.Silverlight.Carousel; |
Visual Basic |
Copy Code
|
---|---|
InitData() |
C# |
Copy Code
|
---|---|
InitData(); |
Visual Basic |
Copy Code
|
---|---|
Private Sub InitData() For i As Integer = 101 To 140 carouselListBox.Items.Add(New BitmapImage(Extensions.GetAbsoluteUri("Resources/covers/cover" & i & ".jpg"))) Next End Sub |
C# |
Copy Code
|
---|---|
private void InitData() { for (int i = 101; i <= 140; ++i) { carouselListBox.Items.Add(new BitmapImage(Extensions.GetAbsoluteUri("Resources/covers/cover" + i + ".jpg"))); } |