【发布时间】:2020-01-30 00:45:47
【问题描述】:
我正在开发一个使用 Xamarin 表单的跨平台项目。我正在使用 carouselview 来显示图像按钮。请参阅下面的代码 sn-ps。 customImageButtonStyle 设置为 Aspect.Aspect.Fit。最初它按预期工作。但是,图像更改后,图像仍然显示,但更小,即。不再做 Aspect.Fit。如果我将相同的代码放在轮播视图之外,它就不会出现这样的问题。
<StackLayout Grid.Row="0" Grid.Column="1" Orientation="Vertical" HorizontalOptions="CenterAndExpand">
<Grid x:Name="relayGrid" HorizontalOptions="CenterAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="4.0*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<views:CustomImageButton x:Name="relayButton" Source="{Binding RelayIcon}" Grid.Row="0" Grid.Column="0"
Style="{StaticResource customImageButtonStyle}"
Command="{Binding NavigateCommand}" CommandParameter="{x:Type views:RelayPage}" />
<Label Text="RELAYS" Grid.Row="1" Grid.Column="0" Style="{StaticResource deviceHomeBottomTextStyle}" />
</Grid>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding NavigateCommand}" CommandParameter="{x:Type views:RelayPage}" />
</StackLayout.GestureRecognizers>
</StackLayout>
</Grid>
</x:Array>
</controls:CarouselViewControl.ItemsSource>
请注意此问题也记录在https://github.com/alexrainman/CarouselView/issues/561
【问题讨论】:
-
,我做了一个关于 CarouselViewControl 的示例,但我无法重现您的问题。您如何更改图像?你能在这里提供一些关于你的问题的截图吗?你能在 github 上提供一个可以重现你的问题的示例,我会下载你的示例进行测试。
-
嗨樱桃,谢谢。我从 C# 中另一个页面的视图模型更改图像。请在github中找到随附的屏幕截图..
-
从 CustomImageButton 更改为 ImageButton 没有区别。方面匹配问题仍然存在。
标签: xamarin.forms imagebutton aspect-fit