问题描述
我正在尝试创建带有ContentView
的可重用错误视图控件,以显示与API调用相关的错误,如无网络,超时,服务器问题,...
此视图将包含:图像,标题和简短说明。就我而言,该图片基于FontimageSource
。
我的ErrorControl
视图如下:
<ContentView.Content>
<Grid>
<Grid.RowDeFinitions>
<RowDeFinition Height="*" />
<RowDeFinition Height="Auto" />
</Grid.RowDeFinitions>
<StackLayout BackgroundColor="Transparent"
Spacing="0"
VerticalOptions="Center">
<Grid>
<Image Style="{StaticResource ErrorImageIconPart1Style}">
<Image.source>
<FontimageSource Glyph="{StaticResource FadsIconNoInternetPart1}"
Color="{StaticResource BlondColor}"
FontFamily="FontAwesomeDuotonesolid"
Size="90" />
</Image.source>
</Image>
</Grid>
<Label Text="{Binding Description,Source={x:Reference ErrorControl}}" />
</StackLayout>
<Button Grid.Row="1"
Text="Retry" />
</Grid>
</ContentView.Content>
我这样使用控件:
<ctrl:ErrorView Title="Title Test"
Description="Description Test"/>
如果我有静态图像,则可以正常工作,但是我需要根据错误类型更改Glyph
使用的FontimageSource
。
什么是实现此目标的更好方法?
- 我曾经考虑使用
Converters
,但是由于我至少有3种错误,这似乎不是一个好方法,因为我必须创建3个转换器 - 我还考虑过使用
DataTemplate
,但是我的图像未包含在“收藏夹/列表”中,因此这似乎并不能满足我的需求
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)