xamarin.forms - 自定义所选元素的外观
解决方案
当您的视图的颜色变化增加视图的宽度时尝试使用触发器,或者您可以使用视图的 PropertyChanged 事件来检测视图的变化。我今天有类似的要求,下面的代码对我有用。
<IndicatorView
x:Name="introductionIndicator"
Grid.Row="2"
HorizontalOptions="Center"
IndicatorColor="{StaticResource PrimaryLightGrayColor}"
SelectedIndicatorColor="{StaticResource PrimaryYellowColor}">
<IndicatorView.IndicatorTemplate>
<DataTemplate>
<BoxView
CornerRadius="10"
HeightRequest="6"
WidthRequest="20">
<BoxView.Triggers>
<Trigger TargetType="BoxView" Property="BackgroundColor" Value="{StaticResource PrimaryYellowColor}">
<Setter Property="WidthRequest" Value="30" />
</Trigger>
</BoxView.Triggers>
</BoxView>
</DataTemplate>
</IndicatorView.IndicatorTemplate>
</IndicatorView>
推荐阅读
- python - 将 Pandas datetimeindex 的频率从每天更改为每小时,以根据每日重采样数据的条件选择每小时数据
- google-bigquery - BigQuery:超过对列分区表的分区修改次数的配额
- javascript - 如何在 jquery for 循环中使用字符串替换?
- java - 实现必须从不同线程添加/删除元素的元素列表的最佳方法是什么?
- python - 没有参数的 Pytest 有错误的工作目录
- python - 无法在 jupyter 笔记本中导入 rmagic
- c++11 - 包括自身在内的 C++ 文件
- ios - Dropbox HTTP 端点挂起并抛出超时
- c# - EF Core 继承问题 (HasDiscriminator)
- javascript - 按类名选择时如何使用 JavaScript 在子节点上查找某些文本