如何从 microsoft.toolkit 自定义轮播
How to customized carousel from microsoft.toolkit
我有一个来自 microsoft.toolkit 的旋转木马
XAML:
<controls:Carousel
x:Name="k2006Carousel"
VerticalAlignment="Center"
ItemDepth="300"
ItemMargin="0"
ItemRotationX="0"
ItemRotationY="-40"
ItemRotationZ="0"
Orientation="Horizontal"
SelectionChanged="bukuCarousel_SelectionChanged">
<controls:Carousel.EasingFunction>
<CubicEase EasingMode="EaseInOut" />
</controls:Carousel.EasingFunction>
<controls:Carousel.ItemTemplate>
<DataTemplate>
-->
<!-- Carousel content -->
<!--
<Grid x:Name="k2006CarouselGrid" Background="{x:Null}">
<Grid PointerPressed="BukuUIElement_OnPointerPressed">
<Image
x:Name="cover"
Width="280"
Margin="0,10,0,10"
HorizontalAlignment="Center"
Source="{Binding Image}"
Stretch="Uniform" />
</Grid>
<Rectangle
Grid.Row="1"
Height="140"
Margin="0,0,0,-130"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#801B1B1B" />
<GradientStop Offset="0.259" Color="#661B1B1B" />
<GradientStop Offset="0.681" Color="Transparent" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</DataTemplate>
</controls:Carousel.ItemTemplate>
</controls:Carousel>
从上面的xaml,输出如下图:
我希望项目之间的边距为 0(无边距),如下图所示:
如何申请?
根据您的要求,您可以为ItemMargin
设置合适的负值。
ItemMargin="-150"
我有一个来自 microsoft.toolkit 的旋转木马 XAML:
<controls:Carousel
x:Name="k2006Carousel"
VerticalAlignment="Center"
ItemDepth="300"
ItemMargin="0"
ItemRotationX="0"
ItemRotationY="-40"
ItemRotationZ="0"
Orientation="Horizontal"
SelectionChanged="bukuCarousel_SelectionChanged">
<controls:Carousel.EasingFunction>
<CubicEase EasingMode="EaseInOut" />
</controls:Carousel.EasingFunction>
<controls:Carousel.ItemTemplate>
<DataTemplate>
-->
<!-- Carousel content -->
<!--
<Grid x:Name="k2006CarouselGrid" Background="{x:Null}">
<Grid PointerPressed="BukuUIElement_OnPointerPressed">
<Image
x:Name="cover"
Width="280"
Margin="0,10,0,10"
HorizontalAlignment="Center"
Source="{Binding Image}"
Stretch="Uniform" />
</Grid>
<Rectangle
Grid.Row="1"
Height="140"
Margin="0,0,0,-130"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#801B1B1B" />
<GradientStop Offset="0.259" Color="#661B1B1B" />
<GradientStop Offset="0.681" Color="Transparent" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</DataTemplate>
</controls:Carousel.ItemTemplate>
</controls:Carousel>
从上面的xaml,输出如下图:
我希望项目之间的边距为 0(无边距),如下图所示:
如何申请?
根据您的要求,您可以为ItemMargin
设置合适的负值。
ItemMargin="-150"