所以我有我的 App.xaml :
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Fitness_App.App">
<Application.Resources>
<ResourceDictionary>
<Style x:Key="WorkoutStyle" TargetType="Label">
<Setter Property="FontSize" Value="28"/>
<Setter Property="FontFamily" Value="BebasNeue"/>
<Setter Property="TextColor" Value="Wheat"/>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
就我閱讀過的 microsoft 檔案而言,我在這里宣告了一種 GLOBALLY 樣式。但是,當我在另一個 xaml 檔案中這樣做時:
<Label Style= "{StaticResource WorkoutStyle}"
它說找不到 WorkoutStyle。知道為什么嗎?
uj5u.com熱心網友回復:
宣告是正確的。只需洗掉目標專案的 obj 和 bin 并進行重建。這將解決問題。
uj5u.com熱心網友回復:
這是作業
<Application.Resources>
<ResourceDictionary>
<Style x:Key="WorkoutStyle" TargetType="Label">
<Setter Property="FontSize" Value="28"/>
<Setter Property="TextColor" Value="Wheat"/>
</Style>
</ResourceDictionary>
</Application.Resources>
這條線不好
<Setter Property="FontFamily" Value="BebasNeue"/>
你的 FontFamily 是錯誤的,看看這里的例子,用你的字體改變它
<Style x:Key="NormalFont" TargetType="Label">
<Setter Property="FontFamily" Value="NunitoSans-Regular.ttf#NunitoSans-Regular.ttf"/>
</Style>
此處解釋 https://www.serkanseker.com/xamarin-forms-custom-font-family/
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/345952.html
標籤:C# xml 沙马林 xamarin.forms 样式
