xaml - Xamarin Style IndicatorView 看起来像 TabbedPage
问题描述
我有个问题。我最近遇到了这个问题:Xamarin 在 TabbedPage 中表单添加按钮,但使用接受的 anwser 已修复。简而言之,我正在使用 aCarouselView
和 an IndicatorView
,因此我可以在多个屏幕上进行叠加。这两个视图都替换了我的TabbedPage
,但IndicatorView
需要看起来像TabbedPageBar
。关于样式化的唯一好页面IndicatorView
是这个:https ://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/indicatorview 。
这是我的页面:
<StackLayout AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
Padding="0"
Spacing="0">
<IndicatorView x:Name="indicatorView">
<IndicatorView.IndicatorTemplate>
<DataTemplate>
<StackLayout HorizontalOptions="FillAndExpand">
<Frame Margin="10">
<Label/>
</Frame>
</StackLayout>
</DataTemplate>
</IndicatorView.IndicatorTemplate>
</IndicatorView>
<CarouselView ItemTemplate="{StaticResource templateSelector}"
IndicatorView="indicatorView">
<CarouselView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>1</x:String>
<x:String>2</x:String>
<x:String>3</x:String>
</x:Array>
</CarouselView.ItemsSource>
</CarouselView>
</StackLayout>
现在我怎样才能让它IndicatorView
看起来像一个TabbedPageBar
?
解决方案
我觉得这里的重点是去掉Shadow
and CornerRadius
of Frame
,然后就可以自定义Frame里面的布局了。这是一个例子:
<IndicatorView x:Name="indicatorView" >
<IndicatorView.IndicatorTemplate>
<DataTemplate>
<StackLayout HorizontalOptions="FillAndExpand" Spacing="0">
<Frame HasShadow="False" CornerRadius="0">
<StackLayout Orientation="Vertical">
<Image Source="Images"/>
<Label Text="123" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
</StackLayout>
</Frame>
</StackLayout>
</DataTemplate>
</IndicatorView.IndicatorTemplate>
</IndicatorView>
推荐阅读
- java - 使用 Spring JPA 和 H2 数据库,应用重启后 ID 不会随之而来
- primeng - Primeng 10 - tabPanel 存在由于 *ngIf 不发生而改变
- python - 如何以编程方式绘制多个变量
- google-apps-script - 执行枢轴操作的 Appscript
- c++ - 是否可以在c ++中获取进程内存中第一个字符串的地址?
- java - SpringBootApplication 无法从新表中获取数据
- c# - 如何使用 context.Database.ExecuteSqlInterpolated?
- javascript - × InvalidCharacterError:无法在“文档”上执行“createElement”:提供的标签名称(“”)不是有效名称
- javascript - 如何从数组中返回所有字符串元素?
- latex - 在 Latex 中用单词而不是点绘制图形