[Xamarin]建立自訂的 Resource Dictionary 檔案
介紹如何在 Xamarin 中建立自訂的 Resource Dictionary (資源字典) 檔案。 最近受到 James Tsai 的感召,開始著手小玩一下 Xamarin.Forms,記得在寫 WPF/UWP 的時候自己常常要自訂一些 Resource Dictionary 檔案,於是小小研究了一下在 Xamarin.Forms 中如何完成這樣的需求。 在 UWP 中我們要新增個 Resource Dictionary 檔案很容易,只要加入新增項目,選擇資源字典就可以了。 接著我們在 Dictionary1.xaml 中設計一個簡單的 Style < ResourceDictionary xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:x = " http://schemas.microsoft.com/winfx/2006/xaml " xmlns:local = "using:App2" > < Style x:Key = "myTextBlockStyle" TargetType = "TextBlock" > < Setter Property =" Foreground " Value =" Red "/> </ Style > </ ResourceDictionary > 接著我們可以在其他的 xaml code 中利用 ResourceDictionary.MergedDictionaries 引用這個 Resource Dictionary < Page x:Class = "App2.MainPage" xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:...