我的 Xamarin Forms 应用程序中有以下按钮
<Button
Grid.Column="1"
Grid.Row="0">
<Button.ImageSource>
<FontImageSource Glyph="" FontFamily="{StaticResource IconFont}" Color="{StaticResource BaseColor}"/>
</Button.ImageSource>
</Button>
哪里IconFont
是: <OnPlatform x:TypeArguments="x:String" x:Key="IconFont">
<On Platform="Android" Value="materialdesignicons-webfont.ttf#Material design" />
<On Platform="iOS" Value="Material Design Icons" />
</OnPlatform>
一切正常。现在,因为我所有的图标都在 materialdesignicons-webfont
我永远不会使用不同的图标,我决定将整个样式移动到 App.xaml。我想设置这样的默认属性: <Style TargetType="FontImageSource">
<Setter Property="FontFamily" Value="{StaticResource IconFont}" />
<Setter Property="Color" Value="{StaticResource BaseColor}" />
</Style>
并仅通过传递字形来使用按钮。 <Button
Grid.Column="1"
Grid.Row="0">
<Button.ImageSource>
<FontImageSource Glyph=""/>
</Button.ImageSource>
</Button>
FontFamily
就不会呈现图标和 Color
直接在FontImageSource
.我错过了什么吗? <Button
Grid.Column="1"
Grid.Row="0"
MDGlyph="" />
最佳答案
不幸的是,无法设置 FontImageSource
的样式目前。但是,有一个 github issue requesting this capability .
关于xamarin.forms - FontImageSource 属性的全局样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58682824/