亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 .NetStandard 中使用 WPF ResourceDictionary

在 .NetStandard 中使用 WPF ResourceDictionary

C#
萬千封印 2023-05-14 16:50:41
我有一些在 WPF 和 ResourceDictionary 中編寫的樣式和自定義控件。現在我想在 xamarin 中使用這些樣式,但我意識到該庫應該基于 .NetStandard 才能安裝在 xamarin 上。但現在我看到 ResourceDictionary 不存在。如何將我的 WPF 代碼升級到 xamarin?
查看完整描述

1 回答

?
德瑪西亞99

TA貢獻1770條經驗 獲得超3個贊

不幸的是,Xamarin 不能使用 WPF 的 ResourceDictionary。

您可以創建和使用 Xamarin 的 ResourceDictionary,如下所示。

<Application ...>

? ? <Application.Resources>

? ? ? ? <ResourceDictionary>

? ? ? ? ? ? <Color x:Key="PageBackgroundColor">Yellow</Color>

? ? ? ? ? ? <Color x:Key="HeadingTextColor">Black</Color>

? ? ? ? ? ? <Color x:Key="NormalTextColor">Blue</Color>

? ? ? ? ? ? <Style x:Key="LabelPageHeadingStyle" TargetType="Label">

? ? ? ? ? ? ? ? <Setter Property="FontAttributes" Value="Bold" />

? ? ? ? ? ? ? ? <Setter Property="HorizontalOptions" Value="Center" />

? ? ? ? ? ? ? ? <Setter Property="TextColor" Value="{StaticResource HeadingTextColor}" />

? ? ? ? ? ? </Style>

? ? ? ? </ResourceDictionary>

? ? </Application.Resources>

</Application>


查看完整回答
反對 回復 2023-05-14
  • 1 回答
  • 0 關注
  • 153 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號